mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-05-06 07:23:31 +08:00
add reading time feature
This commit is contained in:
parent
325303a7f8
commit
73748a364e
9
assets/icons/date.svg
Normal file
9
assets/icons/date.svg
Normal 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 |
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"*": [
|
"*": [
|
||||||
"*"
|
"*"
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,34 +6,31 @@
|
|||||||
</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 ") -}}
|
||||||
</time>
|
{{ .ReadingTime }} min read</time>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
|
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
|
||||||
{{ if $image.exists }}
|
{{ if $image.exists }}
|
||||||
<div class="article-image">
|
<div class="article-image">
|
||||||
{{ if $image.resource }}
|
{{ if $image.resource }}
|
||||||
{{- $Permalink := $image.resource.RelPermalink -}}
|
{{- $Permalink := $image.resource.RelPermalink -}}
|
||||||
{{- $Width := $image.resource.Width -}}
|
{{- $Width := $image.resource.Width -}}
|
||||||
{{- $Height := $image.resource.Height -}}
|
{{- $Height := $image.resource.Height -}}
|
||||||
|
|
||||||
{{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
|
{{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
|
||||||
{{- $thumbnail := $image.resource.Fill "120x120" -}}
|
{{- $thumbnail := $image.resource.Fill "120x120" -}}
|
||||||
{{- $Permalink = $thumbnail.RelPermalink -}}
|
{{- $Permalink = $thumbnail.RelPermalink -}}
|
||||||
{{- $Width = $thumbnail.Width -}}
|
{{- $Width = $thumbnail.Width -}}
|
||||||
{{- $Height = $thumbnail.Height -}}
|
{{- $Height = $thumbnail.Height -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
<img src="{{ $Permalink }}"
|
<img src="{{ $Permalink }}" width="{{ $Width }}" height="{{ $Height }}" loading="lazy">
|
||||||
width="{{ $Width }}"
|
{{ else }}
|
||||||
height="{{ $Height }}"
|
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
||||||
loading="lazy">
|
{{ end }}
|
||||||
{{ else }}
|
</div>
|
||||||
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</a>
|
</a>
|
||||||
</article>
|
</article>
|
@ -2,9 +2,10 @@
|
|||||||
{{ 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 }}"
|
||||||
{{ .LinkTitle }}
|
{{ with .Params.style }}style="background-color: {{ .background }}; color: {{ .color }};" {{ end }}>
|
||||||
</a>
|
{{ .LinkTitle }}
|
||||||
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</header>
|
</header>
|
||||||
{{ 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") -}} 
|
||||||
|
</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 -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user