Lastmod is autopopulated from Date if not set.

This commit is contained in:
Fredrik Jonsson 2017-09-01 15:28:44 +02:00
commit 1b0cead11a
3 changed files with 2 additions and 10 deletions

View file

@ -26,11 +26,7 @@
{ {
"title" : {{ .Title | jsonify }}, "title" : {{ .Title | jsonify }},
"date_published" : "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}", "date_published" : "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}",
{{ if .Lastmod -}} "date_modified" : "{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}",
"date_modified" : "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}",
{{ else -}}
"date_modified" : "{{ .LastMod.Format "2006-01-02T15:04:05Z07:00" }}",
{{ end -}}
"id" : "{{ .Permalink }}", "id" : "{{ .Permalink }}",
"url" : "{{ .Permalink }}", "url" : "{{ .Permalink }}",
{{ with .Params.author -}} {{ with .Params.author -}}

View file

@ -13,7 +13,7 @@
<div class="content"> <div class="content">
{{ .Content }} {{ .Content }}
{{ if not .Lastmod.IsZero }}{{ partial "dates.html" . }}{{ end -}} {{ if ne .Lastmod .Date }}{{ partial "dates.html" . }}{{ end -}}
</div> </div>
</article> </article>
</main> </main>

View file

@ -1,8 +1,4 @@
<p class="submitted"> <p class="submitted">
{{ with $.Param "author" }}<span class="author">{{ . }}</span> – {{ end -}} {{ with $.Param "author" }}<span class="author">{{ . }}</span> – {{ end -}}
{{ if not .Lastmod.IsZero -}}
<time class="modified-date" datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Lastmod.Format ($.Param "dateformat" | default "2 January, 2006") }}</time> <time class="modified-date" datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Lastmod.Format ($.Param "dateformat" | default "2 January, 2006") }}</time>
{{ else -}}
<time class="modified-date" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format ($.Param "dateformat" | default "2 January, 2006") }}</time>
{{ end -}}
</p> </p>