Update post-metadata to use a partial, and add word count

This commit is contained in:
BBaoVanC 2021-10-09 18:08:27 -05:00
parent 4dc429ce5d
commit c8874736ea
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
4 changed files with 41 additions and 59 deletions

View File

@ -29,8 +29,12 @@
margin-top: 5px; margin-top: 5px;
} }
.wordcount {
margin-left: 5px;
}
.tags { .tags {
margin-left: 10px; margin-top: 5px;
} }
.tag { .tag {

View File

@ -3,35 +3,7 @@
<h1>{{ .Title | markdownify }}</h1> <h1>{{ .Title | markdownify }}</h1>
</div> </div>
{{ if or .Date (.GetTerms "tags") }} {{ partial "post-metadata.html" . }}
<div class="post-metadata">
{{ if .Date }}
<span class="date">
{{ partial "icon.html" "calendar" }}
<time datetime="{{ .Date.Format "2006-01-02" }}" pubdate>
{{ .Date.Format "January 2, 2006" }}
</time>
{{ if ne .Lastmod .Date }}
<time datetime="{{ .Lastmod.Format "2006-01-02" }}" pubdate>
(Modified {{ .Lastmod.Format "January 2, 2006" }})
</time>
{{ end }}
{{ end }}
</span>
<span class="tags">
{{ range (.GetTerms "tags") }}
<span class="tag">
{{ partial "icon.html" "tag" }}
<a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
</span>
{{ end }}
</span>
</div>
{{ end }}
{{ if .Params.Toc }} {{ if .Params.Toc }}
<div id="table-of-contents"> <div id="table-of-contents">

View File

@ -3,35 +3,7 @@
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a> <a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
</h2> </h2>
{{ if or .Date (.GetTerms "tags") }} {{ partial "post-metadata.html" . }}
<div class="post-metadata">
{{ if .Date }}
<span class="date">
{{ partial "icon.html" "calendar" }}
<time datetime="{{ .Date.Format "January 2, 2006" }}" pubdate>
{{ .Date.Format "January 2, 2006" }}
</time>
{{ if ne .Lastmod .Date }}
<time datetime="{{ .Lastmod.Format "2006-01-02" }}" pubdate>
(Modified {{ .Lastmod.Format "January 2, 2006" }})
</time>
{{ end }}
{{ end }}
</span>
<span class="tags">
{{ range (.GetTerms "tags") }}
<span class="tag">
{{ partial "icon.html" "tag" }}
<a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
</span>
{{ end }}
</span>
</div>
{{ end }}
{{ with .Resources.GetMatch "feature" }} {{ with .Resources.GetMatch "feature" }}
{{ if eq .MediaType.MainType "image" }} {{ if eq .MediaType.MainType "image" }}

View File

@ -0,0 +1,34 @@
{{ if or .Date (.GetTerms "tags") }}
<div class="post-metadata">
{{ if .Date }}
<span class="date">
{{ partial "icon.html" "calendar" }}
<time datetime="{{ .Date.Format "January 2, 2006" }}" pubdate>
{{ .Date.Format "January 2, 2006" }}
</time>
{{ if ne .Lastmod .Date }}
<time datetime="{{ .Lastmod.Format "2006-01-02" }}" pubdate>
(Modified {{ .Lastmod.Format "January 2, 2006" }})
</time>
{{ end }}
{{ end }}
</span>
<span class="wordcount">
{{ partial "icon.html" "type" }}
{{ .WordCount }} words
</span>
<div class="tags">
{{ range (.GetTerms "tags") }}
<span class="tag">
{{ partial "icon.html" "tag" }}
<a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
</span>
{{ end }}
</div>
</div>
{{ end }}