diff --git a/config/_default/params.toml b/config/_default/params.toml index 875dc423..4d693ddb 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -30,6 +30,7 @@ colorScheme = "congo" showPagination = true showReadingTime = true # sharingLinks = ["facebook", "twitter", "pinterest", "reddit", "linkedin", "email"] + showWordCount = true [list] showBreadcrumbs = false diff --git a/i18n/en.yaml b/i18n/en.yaml index 1c539b3b..d8de5fee 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -6,6 +6,7 @@ article: one: "{{ .Count }} min" other: "{{ .Count }} mins" reading_time_title: "Reading time" + word_count_unit: "Words" author: byline_title: "Author" diff --git a/i18n/zh.yaml b/i18n/zh.yaml index 175208a0..a539072d 100644 --- a/i18n/zh.yaml +++ b/i18n/zh.yaml @@ -5,6 +5,7 @@ article: reading_time: other: "{{ .Count }} 分钟" reading_time_title: "预计阅读" + word_count_unit: "字" author: byline_title: "作者" diff --git a/layouts/partials/article-meta.html b/layouts/partials/article-meta.html index e2118119..c0e2a8f3 100644 --- a/layouts/partials/article-meta.html +++ b/layouts/partials/article-meta.html @@ -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 }} diff --git a/layouts/partials/meta/word-count.html b/layouts/partials/meta/word-count.html new file mode 100644 index 00000000..6907581d --- /dev/null +++ b/layouts/partials/meta/word-count.html @@ -0,0 +1,5 @@ + + {{ .WordCount }} {{- i18n "article.word_count_unit" -}} + +{{- /* Trim EOF */ -}} + \ No newline at end of file