From bcb4d7b2d73ca4386a7485ddb696ad66bbbc68b7 Mon Sep 17 00:00:00 2001 From: Laborratte5 Date: Fri, 6 Sep 2024 19:37:33 +0200 Subject: [PATCH 1/2] feat: add option for post date format Add extra option to change the date format displayed at the beginning of the single.html --- exampleSite/hugo.toml | 4 ++++ layouts/_default/single.html | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 3af9687..5303072 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -90,6 +90,7 @@ theme = "hugo-blog-awesome" # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "" # date format used to show dates on various pages. If nothing is specified, then "2 Jan 2006" format is used. + postDateFormat = "" # date format used to show the published date at the beginning of each post. If nothing is specified, then ":date_medium" format is used. # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. rssFeedDescription = "summary" # available options: 1) summary 2) full # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . @@ -154,6 +155,7 @@ theme = "hugo-blog-awesome" # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "2 January 2006" # default date format used on various pages + postDateFormat = "" # date format used to show the published date at the beginning of each post. If nothing is specified, then ":date_medium" format is used. # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. rssFeedDescription = "summary" # available options: 1) summary 2) full # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . @@ -219,6 +221,7 @@ theme = "hugo-blog-awesome" # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "" # date format used to show dates on various pages. If nothing is specified, then "2 Jan 2006" format is used. + postDateFormat = "" # date format used to show the published date at the beginning of each post. If nothing is specified, then ":date_medium" format is used. # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. rssFeedDescription = "summary" # available options: 1) summary 2) full # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . @@ -284,6 +287,7 @@ theme = "hugo-blog-awesome" # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "" # date format used to show dates on various pages. If nothing is specified, then "2 Jan 2006" format is used. + postDateFormat = "" # date format used to show the published date at the beginning of each post. If nothing is specified, then ":date_medium" format is used. # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. rssFeedDescription = "summary" # available options: 1) summary 2) full # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 9e2e95c..847ec30 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -4,10 +4,11 @@

{{ .Title }}

+ {{ $configDateFormat := .Site.Params.postDateFormat | default ":date_medium" }} {{ with .Date }} {{ $ISO_time := dateFormat "2006-01-02T15:04:05-07:00" . }} {{ end }}
From 7a4fcdd296d909f738abe6827dd14c156ca14b8d Mon Sep 17 00:00:00 2001 From: Laborratte5 Date: Sat, 7 Sep 2024 12:57:14 +0200 Subject: [PATCH 2/2] Use dateFormat option instead of postDateFormat --- exampleSite/hugo.toml | 4 ---- layouts/_default/single.html | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 5303072..3af9687 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -90,7 +90,6 @@ theme = "hugo-blog-awesome" # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "" # date format used to show dates on various pages. If nothing is specified, then "2 Jan 2006" format is used. - postDateFormat = "" # date format used to show the published date at the beginning of each post. If nothing is specified, then ":date_medium" format is used. # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. rssFeedDescription = "summary" # available options: 1) summary 2) full # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . @@ -155,7 +154,6 @@ theme = "hugo-blog-awesome" # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "2 January 2006" # default date format used on various pages - postDateFormat = "" # date format used to show the published date at the beginning of each post. If nothing is specified, then ":date_medium" format is used. # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. rssFeedDescription = "summary" # available options: 1) summary 2) full # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . @@ -221,7 +219,6 @@ theme = "hugo-blog-awesome" # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "" # date format used to show dates on various pages. If nothing is specified, then "2 Jan 2006" format is used. - postDateFormat = "" # date format used to show the published date at the beginning of each post. If nothing is specified, then ":date_medium" format is used. # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. rssFeedDescription = "summary" # available options: 1) summary 2) full # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . @@ -287,7 +284,6 @@ theme = "hugo-blog-awesome" # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "" # date format used to show dates on various pages. If nothing is specified, then "2 Jan 2006" format is used. - postDateFormat = "" # date format used to show the published date at the beginning of each post. If nothing is specified, then ":date_medium" format is used. # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. rssFeedDescription = "summary" # available options: 1) summary 2) full # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 847ec30..654596e 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -4,7 +4,7 @@

{{ .Title }}

- {{ $configDateFormat := .Site.Params.postDateFormat | default ":date_medium" }} + {{ $configDateFormat := .Site.Params.dateFormat | default ":date_medium" }} {{ with .Date }} {{ $ISO_time := dateFormat "2006-01-02T15:04:05-07:00" . }}