display lastmod date if set and different from original post date

This commit is contained in:
John Bowdre 2021-12-20 16:00:09 -06:00
parent 42a1f37803
commit 19314ceff8
2 changed files with 45 additions and 1 deletions

View file

@ -11,4 +11,7 @@ other = "All Rights Reserved"
other = "Powered by" other = "Powered by"
[and] [and]
other = "and" other = "and"
[updated]
other = "Updated"

View file

@ -0,0 +1,41 @@
{{- $showShare := ne (.Param "showshare") false }}
{{- $showDate := ne (.Param "showdate") false }}
{{- $postDate := .Date.Format (default "Jan 2, 2006" $.Site.Params.dateFormat) }}
{{- $updateDate := .Lastmod.Format (default "Jan 2, 2006" $.Site.Params.dateFormat) }}
{{- $showReadTime := ne (.Param "showreadtime") false }}
{{- $showPostMeta := or ($showShare) ($showDate) ($showReadTime) (isset .Params "tags") }}
{{- $scratch := newScratch }}
{{- $scratch.Set "writeSeparator" false }}
{{- if $showPostMeta }}
<div class="post_meta">
{{- end }}
{{- if $showDate }}
<span>{{ partial "sprite" (dict "icon" "calendar") }}</span>
<span class="post_date">
{{ $postDate -}}{{- if ne $postDate $updateDate }} ({{ T "updated" }}: {{ $updateDate -}}){{- end }}
</span>
{{- $scratch.Set "writeSeparator" true }}
{{- end }}
{{- if $showReadTime }}
<span class="post_time">{{ if ($scratch.Get "writeSeparator") }} · {{ end }}{{ T "reading_time" . }}</span>
{{- $scratch.Set "writeSeparator" true }}
{{- end }}
{{- with .Params.tags -}}
<span>
{{- if ($scratch.Get "writeSeparator") }}&nbsp;· {{ end }}
{{- range . }}
{{- $tag := urlize . -}}
<a href='{{ absLangURL (printf "tags/%s" $tag) }}' title="{{ . }}" class="post_tag button button_translucent">
{{- . }}
</a>
{{- end }}
</span>
{{- $scratch.Set "writeSeparator" true }}
{{- end }}
{{- if $showShare }}
<span class="page_only">{{ if ($scratch.Get "writeSeparator") }}&nbsp;·{{ end }}{{ partial "share" . }}</span>
{{- $scratch.Set "writeSeparator" true }}
{{- end }}
{{- if $showPostMeta }}
</div>
{{- end }}