mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 10:21:46 +01:00
feat(article): reading time (#204)
* add reading time feature * Revert change in jsconfig.json * feat: add article.readingTime param, and improve style * Revert change in jsconfig.json x2 * Remove reading time in compact layout It doesn't look right to me for now * feat: add i18n support to reading time string * Hide footer.article-time when there's not content Co-authored-by: Jimmy Cai <github@jimmycai.com>
This commit is contained in:
parent
a25e6463bd
commit
dcfc7b5589
5 changed files with 41 additions and 6 deletions
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 |
|
@ -95,7 +95,9 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
color: var(--card-text-color-tertiary);
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
svg {
|
||||
vertical-align: middle;
|
||||
|
@ -108,6 +110,11 @@
|
|||
time {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
& > div {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.article-category,
|
||||
|
|
|
@ -44,6 +44,7 @@ params:
|
|||
article:
|
||||
math: false
|
||||
toc: true
|
||||
readingTime: true
|
||||
license:
|
||||
enabled: true
|
||||
default: Licensed under CC BY-NC-SA 4.0
|
||||
|
|
|
@ -29,6 +29,11 @@ article:
|
|||
lastUpdatedOn:
|
||||
other: Last updated on
|
||||
|
||||
readingTime:
|
||||
one: "{{ .Count }} min read"
|
||||
### Seems that there's no need to add 's' even if it's plural in English
|
||||
other: "{{ .Count }} min read"
|
||||
|
||||
notFound:
|
||||
title:
|
||||
other: Not Found
|
||||
|
|
|
@ -21,12 +21,25 @@
|
|||
</h3>
|
||||
{{ end }}
|
||||
|
||||
{{- if not .Date.IsZero -}}
|
||||
{{ if or (not .Date.IsZero) (.Site.Params.article.readingTime) }}
|
||||
<footer class="article-time">
|
||||
{{ partial "helper/icon" "clock" }}
|
||||
<time class="article-time--published">
|
||||
{{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}
|
||||
</time>
|
||||
{{ if not .Date.IsZero }}
|
||||
<div>
|
||||
{{ partial "helper/icon" "date" }}
|
||||
<time class="article-time--published">
|
||||
{{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}
|
||||
</time>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ if .Site.Params.article.readingTime }}
|
||||
<div>
|
||||
{{ partial "helper/icon" "clock" }}
|
||||
<time class="article-time--reading">
|
||||
{{ T "article.readingTime" .ReadingTime }}
|
||||
</time>
|
||||
</div>
|
||||
{{ end }}
|
||||
</footer>
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
</div>
|
Loading…
Reference in a new issue