-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add support for custom footer #518
base: main
Are you sure you want to change the base?
Changes from 10 commits
aea9235
0c2c148
756769d
71b2b11
797b485
869731e
aa557df
13e11d5
1a5a34b
e3d29ca
243f4f5
c36a1ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{{- $enableFooterSwitches := .Scratch.Get "enableFooterSwitches" | default false -}} | ||
{{- $displayThemeToggle := site.Params.theme.displayToggle | default true -}} | ||
{{- $footerSwitchesVisible := and $enableFooterSwitches (or hugo.IsMultilingual $displayThemeToggle) -}} | ||
{{- $copyrightSectionVisible := or (.Site.Params.footer.displayPoweredBy | default true) .Site.Params.footer.displayCopyright -}} | ||
|
||
{{- $copyright := (T "copyright") | default "© 2024 Hextra." -}} | ||
{{- $poweredBy := (T "poweredBy") | default "Powered by Hextra" -}} | ||
|
@@ -15,7 +17,7 @@ | |
|
||
|
||
<footer class="hextra-footer hx-bg-gray-100 hx-pb-[env(safe-area-inset-bottom)] dark:hx-bg-neutral-900 print:hx-bg-transparent"> | ||
{{- if and $enableFooterSwitches (or hugo.IsMultilingual $displayThemeToggle) -}} | ||
{{- if $footerSwitchesVisible -}} | ||
<div class="hx-mx-auto hx-flex hx-gap-2 hx-py-2 hx-px-4 {{ $footerWidth }}"> | ||
{{- partial "language-switch.html" (dict "context" .) -}} | ||
{{- with $displayThemeToggle }}{{ partial "theme-toggle.html" }}{{ end -}} | ||
|
@@ -24,14 +26,21 @@ | |
<hr class="dark:hx-border-neutral-800" /> | ||
{{- end -}} | ||
{{- end -}} | ||
<div | ||
class="{{ $footerWidth }} hx-mx-auto hx-flex hx-justify-center hx-py-12 hx-pl-[max(env(safe-area-inset-left),1.5rem)] hx-pr-[max(env(safe-area-inset-right),1.5rem)] hx-text-gray-600 dark:hx-text-gray-400 md:hx-justify-start" | ||
> | ||
<div class="hx-flex hx-w-full hx-flex-col hx-items-center sm:hx-items-start"> | ||
{{- if (.Site.Params.footer.displayPoweredBy | default true) }}<div class="hx-font-semibold">{{ template "theme-credit" $poweredBy }}</div>{{ end }} | ||
{{- if .Site.Params.footer.displayCopyright }}<div class="hx-mt-6 hx-text-xs">{{ $copyright | markdownify }}</div>{{ end }} | ||
<div | ||
class="{{ $footerWidth }} hx-pl-[max(env(safe-area-inset-left),0rem)] hx-pr-[max(env(safe-area-inset-right),0rem)] hx-text-gray-600 dark:hx-text-gray-400" | ||
> | ||
{{ partial "custom/footer.html" (dict "context" . "aboveVisible" $footerSwitchesVisible "belowVisible" $copyrightSectionVisible ) }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what are these variables used for exactly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Solving that with only CSS in custom.css might be impossible or extremely hacky, so it's useful to expose this in case users want to change the content or styling of the custom footer based on what is above.
|
||
</div> | ||
</div> | ||
{{- if $copyrightSectionVisible -}} | ||
<div | ||
class="{{ $footerWidth }} hx-mx-auto hx-flex hx-justify-center hx-py-12 hx-pl-[max(env(safe-area-inset-left),1.5rem)] hx-pr-[max(env(safe-area-inset-right),1.5rem)] hx-text-gray-600 dark:hx-text-gray-400 md:hx-justify-start" | ||
> | ||
<div class="hx-flex hx-w-full hx-flex-col hx-items-center sm:hx-items-start hx-gap-6"> | ||
{{- if (.Site.Params.footer.displayPoweredBy | default true) }}<div class="hx-font-semibold">{{ template "theme-credit" $poweredBy }}</div>{{ end }} | ||
{{- if .Site.Params.footer.displayCopyright }}<div class="hx-text-xs">{{ $copyright | markdownify }}</div>{{ end }} | ||
</div> | ||
</div> | ||
{{- end -}} | ||
</footer> | ||
|
||
{{- define "theme-credit" -}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer keep the left and right padding, e.g.
to make this section styling more consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, but I will add a custom class so people can customize its style