From f38aa2904e02c9d0fc6243ea64dd4e4ffddcb36d Mon Sep 17 00:00:00 2001 From: Nick Savage Date: Wed, 25 Sep 2024 21:16:49 +0100 Subject: [PATCH] Optionally show last modified on single template. if `params.showLastmod: true` and `.Lastmod`'s timestamp is greater than `.Date`, show the last modified date next to the publish date. --- layouts/_default/single.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 000977a..ecd18cc 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -26,6 +26,13 @@ {{end}} + {{ if and (default false (.Param "showLastmod")) (gt .Lastmod .Date) }} + {{ $dateMachine := .Lastmod | time.Format "2006-01-02T15:04:05-07:00" }} + {{ $dateHuman := .Lastmod | time.Format (default ":date_long" $.Site.Params.singleDateFormat) }} +   ·   + Updated + {{end}} + {{ if .Param "readTime" }}   ·   {{ .ReadingTime }} min read @@ -96,4 +103,4 @@ -{{ end }} \ No newline at end of file +{{ end }}