diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 87ba743..d896021 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -164,7 +164,7 @@ params: yearFormat: "2006" monthFormat: "01-02" dateFormat: "2006-01-02" - timeFormat: "2006-01-02T15:04:05-07:00" + timeFormat: "2006-01-02 15:04:05 -07:00" # 页面模式 # Schemes diff --git a/layouts/partials/_funs/cal_siteinfo.html b/layouts/partials/_funs/cal_siteinfo.html index b1fe5ab..2f0f714 100644 --- a/layouts/partials/_funs/cal_siteinfo.html +++ b/layouts/partials/_funs/cal_siteinfo.html @@ -1,3 +1,4 @@ +{{/** Calculate some information for site operation **/}} {{ $scratch := newScratch }} {{ $pages := (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections).ByLastmod.Reverse }} @@ -7,10 +8,11 @@ {{ end }} {{ range first 1 $pages }} - {{ $scratch.Set "first" (time.Format .Site.Params.timeFormat .Date) }} + {{ $lastMod := default .Date .Lastmod }} + {{ $scratch.Set "first" $lastMod }} {{ end }} {{ range last 1 $pages }} - {{ $scratch.Set "last" (time.Format .Site.Params.timeFormat .Date) }} + {{ $scratch.Set "last" .Date }} {{ end }} {{ return $scratch }} \ No newline at end of file diff --git a/layouts/partials/post/header_meta/created_date.html b/layouts/partials/post/header_meta/created_date.html index a1aa316..2c3945f 100644 --- a/layouts/partials/post/header_meta/created_date.html +++ b/layouts/partials/post/header_meta/created_date.html @@ -1,6 +1,6 @@ {{ if .Site.Params.postMeta.created }} -{{ $timeF := .Site.Params.timeFormat }} -{{ $createdTime := (.Date.Format $timeF) | default (.Date.Format $timeF) }} +{{ $createdDate := .Date.Format .Site.Params.dateFormat }} +{{ $createdTime := .Date.Format .Site.Params.timeFormat }} @@ -8,8 +8,8 @@ - {{ end }} \ No newline at end of file diff --git a/layouts/partials/post/header_meta/update_date.html b/layouts/partials/post/header_meta/update_date.html index 6e21c46..9b33359 100644 --- a/layouts/partials/post/header_meta/update_date.html +++ b/layouts/partials/post/header_meta/update_date.html @@ -1,5 +1,6 @@ {{ if and .Site.Params.postMeta.updated.enable .Site.Params.postMeta.updated.anotherDay }} {{ if and .Lastmod (gt .Lastmod .Date) }} +{{ $modDate := .Lastmod.Format .Site.Params.dateFormat }} {{ $modTime := .Lastmod.Format .Site.Params.timeFormat }} {{ end }} {{ end }} \ No newline at end of file