diff options
author | Lars Kruse <devel@sumpfralle.de> | 2021-10-01 20:45:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 20:45:22 +0300 |
commit | b0bf3ccca1a431feb7b788b2ec1210aa903bed97 (patch) | |
tree | b86ac2f3a0b08aea11a8ad868bddb79514f4bda5 /layouts | |
parent | 775277039eab2161823621329902622b1cc17a23 (diff) |
Allow override of date format (#291)
Previously the default date format (`January 2, 2006` ) was used for
blog and single page date visualizations.
The new parameter `date_format` can be used to override this format.
This allows the visualization of localized dates or a changed precision
(down to the minute or up to the month or year of publication).
Co-authored-by: Regis Philibert <login@regisphilibert.com>
Diffstat (limited to 'layouts')
-rwxr-xr-x | layouts/_default/single.html | 2 | ||||
-rw-r--r-- | layouts/post/summary.html | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 0c7b97b..fe2c3b3 100755 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -32,7 +32,7 @@ {{/* Hugo uses Go's date formatting is set by example. Here are two formats */}} {{ if not .Date.IsZero }} <time class="f6 mv4 dib tracked" {{ printf `datetime="%s"` (.Date.Format "2006-01-02T15:04:05Z07:00") | safeHTMLAttr }}> - {{- .Date.Format "January 2, 2006" -}} + {{- .Date.Format (default "January 2, 2006" .Site.Params.date_format) -}} </time> {{end}} diff --git a/layouts/post/summary.html b/layouts/post/summary.html index b2779cf..5856b4a 100644 --- a/layouts/post/summary.html +++ b/layouts/post/summary.html @@ -1,7 +1,7 @@ <div class="mb3 pa4 mid-gray overflow-hidden"> {{ if .Date }} <div class="f6"> - {{ .Date.Format "January 2, 2006" }} + {{ .Date.Format (default "January 2, 2006" .Site.Params.date_format) }} </div> {{ end }} <h1 class="f3 near-black"> |