nicokaiser / hugo-theme-gallery

Gallery Theme for Hugo
https://nicokaiser.github.io/hugo-theme-gallery/
MIT License
361 stars 107 forks source link

Feature request: Show photo capture date in lightbox #83

Open rjwisloff opened 2 months ago

rjwisloff commented 2 months ago

Adding this in gallery.html after the end of the <figure> tag and before the <meta itemprop...> tag will add the date of capture to the text next to the photo:

<span class="pswp-caption-content">
    {{ with .Title }}{{ . }}<br /><hr />{{ end }}
    {{ with .Date }}{{ . | time.Format ":date_short" }}{{ end }}
 </span>

I tried making this dependent on a parameter setting in hugo.toml, but for some reason e.g. .Site.Params.showDate is not picked up in this section. Perhaps there are scope limitations.

rjwisloff commented 2 months ago

This should work:

In hugo.toml add under [params]a line

   showDate = 'Yes'

and change the section mentioned above to

<span class="pswp-caption-content">
     {{ with .Title }}{{ . }}<br /><hr />{{ end }}
     {{ if eq $.Site.Params.showDate "Yes" }} 
        {{ with .Date }}{{ . | time.Format ":date_short" }}{{ end }}
     {{ end }}
</span>

Setting showDate = 'No' or whatever else than 'Yes' disables showing the date.