funkydan2 / hugo-kiera

Kiera - A Hugo Theme for writing
https://hugo-kiera.netlify.app
MIT License
74 stars 55 forks source link

Dynamic copyright year #71

Open jsumners opened 1 year ago

jsumners commented 1 year ago

I'd like to have the copyright year calculated automatically. To that end, I have followed an article to modify the footer.html like so:

5c5,8
<                 <h6>{{ if .Site.Copyright }}{{ .Site.Copyright | markdownify }} | {{ end }}
---
>                 <h6>
>                   {{ if .Site.Copyright }}
>                     {{ replace .Site.Copyright "{year}" now.Year | markdownify }} | 
>                   {{ end }}

Which means in my config.toml I can have:

copyright = "Copyright ©{year} James Sumners. All rights reserved."

This, of course, has the desired effect. However, as with #70, this means I have to keep track of when footer.html changes upstream and sync changes manually. I haven't really come up with a good solution for this. Do you have an ideas on how we could solve this?

funkydan2 commented 1 year ago

I haven't looked into the documentation for the replace function, but I assume this would be a non-breaking change?

If so, I'd be happy to consider a PR that included this change along with appropriate documentation (maybe a comment in the example hugo.conf).

jsumners commented 1 year ago

🤔 I'll research it soon. It could be that replace does nothing if the token is not found.