From a49f7bd2db6ba3fb7ccb2ba38bb9c7718c936670 Mon Sep 17 00:00:00 2001 From: koirand Date: Tue, 25 Sep 2018 00:27:18 +0900 Subject: [PATCH] :hamster: Add date format option --- exampleSite/config.toml | 2 ++ layouts/_default/list.html | 2 +- layouts/_default/single.html | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index d2ccc53..a708f47 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -14,6 +14,8 @@ pygmentsUseClasses = true Profiles, backgrounds, favorite things etc. """ publicationYear = "2018" + listPageDateFormat = "January, 2006" # See https://gohugo.io/functions/format/ + singlePageDateFormat = "January 2, 2006" # custom_css = ["/css/custom.css"] # custom_js = ["/js/custom.js"] diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 7b62761..365c482 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,6 +1,6 @@ {{ define "main"}}
- {{ range $index, $value := .Pages.GroupByDate "January, 2006" }} + {{ range $index, $value := .Pages.GroupByDate .Site.Params.listPageDateFormat }} {{ if (ne $index 0) }}
{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index ba6fde9..499c41b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,7 +1,7 @@ {{ define "main"}}

{{ .Title }}

-

{{ .Date.Format "January 2, 2006" }}

+

{{ .Date.Format .Site.Params.singlePageDateFormat }}

{{ .Content }}