fix: do not render a date if it is not set

fixes the issue where posts without a date render a date of "January 1, 0001"
This commit is contained in:
Ieuan Jenkins 2021-01-05 14:11:32 +00:00
parent cc963b323f
commit 81d13b5936
No known key found for this signature in database
GPG Key ID: 7B5A41FF6216522C

View File

@ -29,10 +29,12 @@
</strong>
</p>
{{ end }}
{{/* Hugo uses Go's date formatting is set by example. Here are two formats */}}
{{/* Hugo uses Go's date formatting is set by example. Here are two formats. */}}
{{ if .Date }}
<time class="f6 mv4 dib tracked" {{ printf `datetime="%s"` (.Date.Format "2006-01-02T15:04:05Z07:00") | safeHTMLAttr }}>
{{- .Date.Format "January 2, 2006" -}}
</time>
{{ end }}
{{/*
Show "reading time" and "word count" but only if one of the following are true: