add reading time feature

This commit is contained in:
uluumbch 2021-05-08 04:49:12 +07:00
parent 325303a7f8
commit 73748a364e
4 changed files with 45 additions and 34 deletions

9
assets/icons/date.svg Normal file
View File

@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-calendar-time" width="56" height="56" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<path d="M11.795 21h-6.795a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4" />
<circle cx="18" cy="18" r="4" />
<path d="M15 3v4" />
<path d="M7 3v4" />
<path d="M3 11h16" />
<path d="M18 16.496v1.504l1 1" />
</svg>

After

Width:  |  Height:  |  Size: 508 B

View File

@ -5,6 +5,6 @@
"*": [ "*": [
"*" "*"
] ]
}, }
} }
} }

View File

@ -6,8 +6,8 @@
</h2> </h2>
<footer class="article-time"> <footer class="article-time">
<time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'> <time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'>
{{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}} {{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006 ") -}}&nbsp;
</time> {{ .ReadingTime }} min read</time>
</footer> </footer>
</div> </div>
@ -26,10 +26,7 @@
{{- $Height = $thumbnail.Height -}} {{- $Height = $thumbnail.Height -}}
{{- end -}} {{- end -}}
<img src="{{ $Permalink }}" <img src="{{ $Permalink }}" width="{{ $Width }}" height="{{ $Height }}" loading="lazy">
width="{{ $Width }}"
height="{{ $Height }}"
loading="lazy">
{{ else }} {{ else }}
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" /> <img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
{{ end }} {{ end }}

View File

@ -2,7 +2,8 @@
{{ if .Params.categories }} {{ if .Params.categories }}
<header class="article-category"> <header class="article-category">
{{ range (.GetTerms "categories") }} {{ range (.GetTerms "categories") }}
<a href="{{ .RelPermalink }}" {{ with .Params.style }}style="background-color: {{ .background }}; color: {{ .color }};"{{ end }}> <a href="{{ .RelPermalink }}"
{{ with .Params.style }}style="background-color: {{ .background }}; color: {{ .color }};" {{ end }}>
{{ .LinkTitle }} {{ .LinkTitle }}
</a> </a>
{{ end }} {{ end }}
@ -23,9 +24,13 @@
{{- if not .Date.IsZero -}} {{- if not .Date.IsZero -}}
<footer class="article-time"> <footer class="article-time">
{{ partial "helper/icon" "date" }}
<time class="article-time--published">
{{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}&emsp;
</time>
{{ partial "helper/icon" "clock" }} {{ partial "helper/icon" "clock" }}
<time class="article-time--published"> <time class="article-time--published">
{{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}} {{ .ReadingTime }} min read
</time> </time>
</footer> </footer>
{{- end -}} {{- end -}}