Add word count to page meta

pull/57/head
wizardbyron 2021-12-16 17:37:46 +08:00 committed by James Panther
parent 24ce98d1f2
commit 65a7228bfc
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
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 */ -}}