Add word counts in post meta.

pull/54/head
wizardbyron 2021-12-16 12:46:22 +08:00
parent 24ce98d1f2
commit ec13775f4a
5 changed files with 12 additions and 0 deletions

View File

@ -30,6 +30,7 @@ colorScheme = "congo"
showPagination = true
showReadingTime = true
# sharingLinks = ["facebook", "twitter", "pinterest", "reddit", "linkedin", "email"]
showWordCount = true
[list]
showBreadcrumbs = false

View File

@ -6,6 +6,7 @@ article:
one: "{{ .Count }} min"
other: "{{ .Count }} mins"
reading_time_title: "Reading time"
word_count_unit: "Words"
author:
byline_title: "Author"

View File

@ -5,6 +5,7 @@ article:
reading_time:
other: "{{ .Count }} 分钟"
reading_time_title: "预计阅读"
word_count_unit: "字"
author:
byline_title: "作者"

View File

@ -16,6 +16,10 @@
{{ $meta.Add "partials" (slice (partial "meta/date.html" .)) }}
{{ end }}
{{ if and (.Params.showWordCount | default (.Site.Params.article.showWordCount | default true)) (ne .WordCount 0) }}
{{ $meta.Add "partials" (slice (partial "meta/word-count.html" .)) }}
{{ end }}
{{ if and (.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true)) (ne .ReadingTime 0) }}
{{ $meta.Add "partials" (slice (partial "meta/reading-time.html" .)) }}
{{ end }}

View File

@ -0,0 +1,5 @@
<span>
{{ .WordCount }} {{- i18n "article.word_count_unit" -}}
</span>
{{- /* Trim EOF */ -}}