hugo-theme-more-contentful/layouts/partials/components/post-meta.html
Gabriel Arazas 044a9482a7 Fix conditional rendering for post metadata
You would think this is something like this is already in the theme but
it turns out it isn't. This should fix pages that are primarily
non-content (i.e., about pages, contact).
2023-02-27 16:46:11 +08:00

39 lines
1.4 KiB
HTML

{{- /*
The component where it will display the metadata of the post.
*/ -}}
{{- if or .PublishDate .Lastmod }}
{{- $RFC3339 := "2006-01-02T15:04:05Z07:00" }}
<div class="list post__meta" aria-hidden="true">
{{- if .PublishDate -}}
<span>
{{ partial "components/heroicon.html" "calendar" }}
<time datetime="{{ .PublishDate.Format $RFC3339 }}" title="{{ i18n "published_on" }}" style="margin-left: 0.5em;">
{{ .PublishDate.Format "2006-01-02" }}
</time>
</span>
{{- end }}
{{- if ne (.PublishDate.Format "2006-01-02") (.Lastmod.Format "2006-01-02") }}
<span>
{{ partial "components/heroicon.html" "arrow-path" }}
<time datetime="{{ .Lastmod.Format $RFC3339 }}" title="{{ i18n "updated_on" }}" style="margin-left: 0.5em;">
{{ .Lastmod.Format "2006-01-02" }}
</time>
</span>
{{- end }}
{{- /* The authors are appended with 'et al' if there's more than one author in the map. */ -}}
{{- with .Params.author }}
{{- $names := slice }}
{{- range . }}{{ $names = $names | append .name }}{{ end }}
{{- $author := index (first 1 $names) 0 }}
<span data-authors="{{ jsonify $names }}" title="{{ i18n "published_by" }}">
{{ partial "components/heroicon.html" "pencil" }}
<span style="margin-left: 0.5em;">
{{ $author }}{{ if ge (len .) 2 }}, et al.{{ end }}
</span>
</span>
{{- end }}
</div>
{{- end }}