mirror of
https://github.com/foo-dogsquared/hugo-theme-more-contentful.git
synced 2025-01-30 22:57:57 +00:00
Modularize post metadata component
This commit is contained in:
parent
c053d1765d
commit
61228b54c0
@ -32,40 +32,3 @@
|
||||
{{- define "partials/components/heroicon.html" }}
|
||||
{{- partial "components/icon.html" (dict "id" . "output" "icons/generic/%s.svg" "template" "templates/heroicon.svg") }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{- /*
|
||||
The component where it will display the metadata of the post.
|
||||
This is used on list templates but feel free to change that.
|
||||
*/ -}}
|
||||
{{- define "partials/components/post-meta.html" }}
|
||||
<div class="list post__meta">
|
||||
{{- if ne (.PublishDate.Format "2006") "0001" -}}
|
||||
<time datetime="{{ .PublishDate }}">
|
||||
{{ partial "components/heroicon.html" "calendar" }}
|
||||
<span style="margin-left: 0.5em;">{{ .PublishDate.Format "2006-01-02" }}</span>
|
||||
</time>
|
||||
{{- end }}
|
||||
|
||||
{{- if and .GitInfo (ne (.PublishDate.Format "2006-01-02") (.Lastmod.Format "2006-01-02")) }}
|
||||
<time datetime="{{ .Lastmod }}">
|
||||
{{ partial "components/heroicon.html" "refresh" }}
|
||||
<span style="margin-left: 0.5em;">{{ .Lastmod.Format "2006-01-02" }}</span>
|
||||
</time>
|
||||
{{- 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 }}">
|
||||
{{ partial "components/heroicon.html" "pencil" }}
|
||||
<span style="margin-left: 0.5em;">
|
||||
{{ $author }}{{ if ge (len .) 2 }}, et al.{{ end }}
|
||||
</span>
|
||||
</span>
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
{{- end }}
|
||||
|
32
layouts/partials/components/post-meta.html
Normal file
32
layouts/partials/components/post-meta.html
Normal file
@ -0,0 +1,32 @@
|
||||
{{- /*
|
||||
The component where it will display the metadata of the post.
|
||||
This is used on list templates but feel free to change that.
|
||||
*/ -}}
|
||||
<div class="list post__meta">
|
||||
{{- if ne (.PublishDate.Format "2006") "0001" -}}
|
||||
<time datetime="{{ .PublishDate }}">
|
||||
{{ partial "components/heroicon.html" "calendar" }}
|
||||
<span style="margin-left: 0.5em;">{{ .PublishDate.Format "2006-01-02" }}</span>
|
||||
</time>
|
||||
{{- end }}
|
||||
|
||||
{{- if and .GitInfo (ne (.PublishDate.Format "2006-01-02") (.Lastmod.Format "2006-01-02")) }}
|
||||
<time datetime="{{ .Lastmod }}">
|
||||
{{ partial "components/heroicon.html" "refresh" }}
|
||||
<span style="margin-left: 0.5em;">{{ .Lastmod.Format "2006-01-02" }}</span>
|
||||
</time>
|
||||
{{- 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 }}">
|
||||
{{ partial "components/heroicon.html" "pencil" }}
|
||||
<span style="margin-left: 0.5em;">
|
||||
{{ $author }}{{ if ge (len .) 2 }}, et al.{{ end }}
|
||||
</span>
|
||||
</span>
|
||||
{{ end }}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user