From 6fa3dfdb7829accd87dc75febd56cd39e7824df1 Mon Sep 17 00:00:00 2001 From: Abizer Nasir Date: Wed, 11 Oct 2023 12:57:54 +0100 Subject: [PATCH] Add site parameters for long and short date formats --- exampleSite/config.yaml | 4 ++++ layouts/_default/list.html | 7 ++++++- layouts/partials/content.header.html | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 9fe28a2..a601d31 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -38,6 +38,10 @@ params: # copyrightHolder: Copyright Holder # Show the "Powered by Hugo-Tufte and Hugo." showPoweredBy: false + # The format to use for short dates shown in lists of posts. Defaults to "Jan 02" + dateFormatShort: "Jan 02" + # The format to use for dates on posts. Defaults to "2006-01-02" + dateFormatLong: "2006-01-02" # Site wide kill switch for date in pages hidedate: false # Site wide kill switch for post summary on home page diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 36e1ec7..86fd74d 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -16,7 +16,12 @@ {{ range .Pages }} diff --git a/layouts/partials/content.header.html b/layouts/partials/content.header.html index d31ebe7..12c2f79 100644 --- a/layouts/partials/content.header.html +++ b/layouts/partials/content.header.html @@ -13,7 +13,12 @@ {{- end -}} {{- if not .Params.hidedate -}} -

{{ .Date.Format "2006-01-02" }}

+

+ {{ if .Site.Params.dateFormatLong }} + {{ .Date.Format .Site.Params.dateFormatLong }} + {{ else }} + {{ .Date.Format "2006-01-02" }} + {{ end }}

{{- end -}} {{- if not .Params.hidereadtime -}}