-
-
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?
Conversation
✅ Deploy Preview for hugo-hextra ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@Gr3q thank you, supporting custom footer is a nice feature to add. I was thinking we can simplify your approach by adding <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 }}
+ {{ partial "custom/footer-end.html" . }}
</div> thus, we can use hugo template syntax like this to render markdown from either in the template or load a param from hugo config file
example hugo.yaml footer:
enable: true
displayCopyright: false
displayPoweredBy: false
width: normal
customFooter: "**custom footer**" # you can change or add your own param output: |
I started with that and I found the padding around too limiting. Still it's a good idea, except the footer should be sandwiched between the copyright/powered by text and the theme buttons (if it's a page that has the theme buttons there) separated by dividers. The reason is that most websites have the copyright section on the very bottom but I can't link to some dataset to back up that claim. |
So I can change the PR to complement the copyright section instead of replacing it. In that case I'll try to upstream some other things in more PRs like changing the footer background/text color and the copyright section layout (centered and in a row instead of having a column) |
layouts/partials/footer.html
Outdated
{{ partial "custom/footer.html" (dict "context" . "footerButtonColor" "hx-rounded-md hx-transition-colors hover:hx-bg-gray-100 hover:hx-text-gray-900 dark:hover:hx-bg-primary-100/5 dark:hover:hx-text-gray-50" ) }} | ||
</div> |
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.
footerButtonColor
is not necessary here right?
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.
Not really, but the other option is to dig through the hextra codebase to match it. I'll remove it.
```yaml {filename="hugo.yaml"} | ||
footer: | ||
enable: true | ||
customSection: true |
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 would avoid adding a new flag if possible
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 can remove it but then I don't know when I should show the separator and when I shouldn't.
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.
Actually, I just remove the separator, people can add it back in their custom footer.
I also added a visually breaking change to only show footer section for Copyright and PoweredBy if at least one of them are enabled. This saves people that don't want the default layout of that section and they want to recreate it in the custom section. Out of the box the footer is there unless people explicitly disable poweredby and the copyright section. Edit: I added 2 necessary variables that you would have a hard time solving with css alone, especially if you want avoid duplicate dividers in all cases. |
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.
Let's keep the left and right padding.
I tried your change with a custom html footer in custom/footer.html
<div style="display: flex; justify-content: space-between; padding-top: 20px;">
<div style="flex: 1;">
<h4 style="margin-bottom: 10px; font-weight: 600;">About Us</h4>
<p>Learn more about our company.</p>
</div>
<div style="flex: 1;">
<h4 style="margin-bottom: 10px; font-weight: 600;">Services</h4>
<ul style="list-style: none; padding: 0;">
<li style="margin: 5px 0;">Web Design</li>
<li style="margin: 5px 0;">SEO</li>
<li style="margin: 5px 0;">Consulting</li>
</ul>
</div>
<div style="flex: 1;">
<h4 style="margin-bottom: 10px; font-weight: 600;">Contact</h4>
<p>Email: [email protected]</p>
<p>Phone: 123-456-7890</p>
</div>
</div>
It works pretty well
layouts/partials/footer.html
Outdated
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" | ||
> |
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.
<div class="{{ $footerWidth }} hx-mx-auto 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" >
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
<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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
aboveVisible
- My use case is that I want to add a separator on the top of my custom footer but on pages where the theme/language switcher is above the footer I would end up with two separators that is visually noticeable.
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.
belowVisible
is the same thing for the PoweredBy/Copyright section but I admit I can't think of a concrete use case for this at the moment. Maybe an user wants to add extra margin on the bottom if the section is not visible? Although currently that section is not dynamic.
See the documentation changes for explanation.
Still, I'm not sure if this is a feature that is wanted as is because it forces you to write html.
Unfortunately I couldn't find a way to use a markdown file as a partial instead unless it's like this https://stackoverflow.com/a/39800156.