feat: enable optional custom date format

Adds a .Site.Params.dateFormat setting to let users specify a Hugo-style
date format string for content. Previously, the date format was
hardcoded to "02 Jan, 2006", presumably to match the original BearBlog
style. This format gets used by default if the new "dateFormat" setting
is absent from the site config.
This commit is contained in:
Akira Baruah 2021-04-05 23:47:59 -07:00 committed by Jan Raasch
parent b1fc6d298f
commit be0ba327e3
3 changed files with 9 additions and 2 deletions

View File

@ -42,3 +42,10 @@ ignoreErrors = ["error-disable-taxonomy"]
# This theme will, by default, inject a made-with-line at the bottom of the page.
# You can turn it off, but we would really appreciate if you dont :-).
# hideMadeWithLine = true
# By default, this theme displays dates with a format like "02 Jan, 2006", but
# you can customize it by setting the `dateFormat` param in your site's config
# file. See [Hugo's Format function docs](https://gohugo.io/functions/format/)
# for details. An example TOML config that uses [ISO
# 8601](https://en.wikipedia.org/wiki/ISO_8601) format:
# dateFormat = "2006-01-02"

View File

@ -12,7 +12,7 @@
<span>
<i>
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
{{ .Date.Format "02 Jan, 2006" }}
{{ .Date.Format (default "02 Jan, 2006" .Site.Params.dateFormat) }}
</time>
</i>
</span>

View File

@ -4,7 +4,7 @@
<p>
<i>
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
{{ .Date.Format "02 Jan, 2006" }}
{{ .Date.Format (default "02 Jan, 2006" .Site.Params.dateFormat) }}
</time>
</i>
</p>