From 65a7228bfc87815c5c49082e21101c68a42a593e Mon Sep 17 00:00:00 2001 From: wizardbyron <1400427+wizardbyron@users.noreply.github.com> Date: Thu, 16 Dec 2021 17:37:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Add=20word=20count=20to=20page?= =?UTF-8?q?=20meta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/_default/params.toml | 1 + i18n/en.yaml | 1 + i18n/zh.yaml | 1 + layouts/partials/article-meta.html | 4 ++++ layouts/partials/meta/word-count.html | 5 +++++ 5 files changed, 12 insertions(+) create mode 100644 layouts/partials/meta/word-count.html 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 From b4cbe9122b8d1ae34b239a52416f271abb411032 Mon Sep 17 00:00:00 2001 From: wizardbyron <1400427+wizardbyron@users.noreply.github.com> Date: Fri, 17 Dec 2021 09:20:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=8C=90=20Pass=20.WordCount=20to=20i18?= =?UTF-8?q?n=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/en.yaml | 4 +++- i18n/zh.yaml | 4 +++- layouts/partials/meta/word-count.html | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/i18n/en.yaml b/i18n/en.yaml index d8de5fee..6cb5c3d5 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -6,7 +6,9 @@ article: one: "{{ .Count }} min" other: "{{ .Count }} mins" reading_time_title: "Reading time" - word_count_unit: "Words" + word_count: + one: "{{ .Count }} word" + other: "{{ .Count }} words" author: byline_title: "Author" diff --git a/i18n/zh.yaml b/i18n/zh.yaml index a539072d..ec93aa7e 100644 --- a/i18n/zh.yaml +++ b/i18n/zh.yaml @@ -5,7 +5,9 @@ article: reading_time: other: "{{ .Count }} 分钟" reading_time_title: "预计阅读" - word_count_unit: "字" + word_count: + one: "{{ .Count }} 字" + other: "{{ .Count }} 字" author: byline_title: "作者" diff --git a/layouts/partials/meta/word-count.html b/layouts/partials/meta/word-count.html index 6907581d..e68ec0d6 100644 --- a/layouts/partials/meta/word-count.html +++ b/layouts/partials/meta/word-count.html @@ -1,5 +1,5 @@ - {{ .WordCount }} {{- i18n "article.word_count_unit" -}} + {{- i18n "article.word_count" .WordCount | emojify -}} {{- /* Trim EOF */ -}} \ No newline at end of file From e1974344bedfa6fc9d4209d0cb584cd807d2f13c Mon Sep 17 00:00:00 2001 From: James Panther <4462786+jpanther@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:55:53 +1100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8C=90=20Add=20placeholder=20i18n=20s?= =?UTF-8?q?trings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/de.yaml | 3 +++ i18n/es.yaml | 3 +++ i18n/fr.yaml | 3 +++ i18n/pt-BR.yaml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/i18n/de.yaml b/i18n/de.yaml index 7cdc20e3..631707bd 100644 --- a/i18n/de.yaml +++ b/i18n/de.yaml @@ -6,6 +6,9 @@ article: one: "{{ .Count }} min" other: "{{ .Count }} min" reading_time_title: "Lesezeit" + # word_count: + # one: "{{ .Count }} word" + # other: "{{ .Count }} words" author: byline_title: "Autor" diff --git a/i18n/es.yaml b/i18n/es.yaml index 4a7df79b..c8afbc09 100644 --- a/i18n/es.yaml +++ b/i18n/es.yaml @@ -6,6 +6,9 @@ article: one: "{{ .Count }} min" other: "{{ .Count }} mins" reading_time_title: "Tiempo de lectura" + # word_count: + # one: "{{ .Count }} word" + # other: "{{ .Count }} words" author: byline_title: "Autor" diff --git a/i18n/fr.yaml b/i18n/fr.yaml index bfe438fd..b3078535 100644 --- a/i18n/fr.yaml +++ b/i18n/fr.yaml @@ -6,6 +6,9 @@ article: one: "{{ .Count }} min" other: "{{ .Count }} mins" reading_time_title: "Temps de lecture" + # word_count: + # one: "{{ .Count }} word" + # other: "{{ .Count }} words" author: byline_title: "Auteur" diff --git a/i18n/pt-BR.yaml b/i18n/pt-BR.yaml index 6e5b7d2f..2396bc7b 100644 --- a/i18n/pt-BR.yaml +++ b/i18n/pt-BR.yaml @@ -6,6 +6,9 @@ article: one: "{{ .Count }} minuto" other: "{{ .Count }} minutos" reading_time_title: "Tempo de leitura" + # word_count: + # one: "{{ .Count }} word" + # other: "{{ .Count }} words" author: byline_title: "Autor"