From b0ab8ea4959c07fe13c1667297e986e1d65aafe1 Mon Sep 17 00:00:00 2001 From: Thiago Perrotta Date: Fri, 21 Jan 2022 13:28:25 -0500 Subject: [PATCH] Add option to add word count to metadata (#740) Usage: ShowWordCount: true --- i18n/de.yaml | 5 +++++ i18n/en.yaml | 5 +++++ i18n/es.yaml | 7 ++++++- i18n/fr.yaml | 5 +++++ i18n/it.yaml | 5 +++++ i18n/nl.yaml | 5 +++++ i18n/pt.yaml | 5 +++++ layouts/partials/post_meta.html | 4 ++++ 8 files changed, 40 insertions(+), 1 deletion(-) diff --git a/i18n/de.yaml b/i18n/de.yaml index 9a816e4a..47254190 100644 --- a/i18n/de.yaml +++ b/i18n/de.yaml @@ -9,6 +9,11 @@ one: "1 Minute" other: "{{ .Count }} Minuten" +- id: words + translation: + one : "Wort" + other: "{{ .Count }} Wörter" + - id: toc translation: "Inhaltsverzeichnis" diff --git a/i18n/en.yaml b/i18n/en.yaml index 4758d365..3dc15790 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -9,6 +9,11 @@ one : "1 min" other: "{{ .Count }} min" +- id: words + translation: + one : "word" + other: "{{ .Count }} words" + - id: toc translation: "Table of Contents" diff --git a/i18n/es.yaml b/i18n/es.yaml index 5e90ebbf..163bfc41 100644 --- a/i18n/es.yaml +++ b/i18n/es.yaml @@ -9,6 +9,11 @@ one : "1 min" other: "{{ .Count }} min" +- id: words + translation: + one : "palabra" + other: "{{ .Count }} palabras" + - id: toc translation: "Tabla de Contenidos" @@ -25,4 +30,4 @@ translation: "copiar" - id: code_copied - translation: "¡copiado!" \ No newline at end of file + translation: "¡copiado!" diff --git a/i18n/fr.yaml b/i18n/fr.yaml index 2e652114..46ad398b 100644 --- a/i18n/fr.yaml +++ b/i18n/fr.yaml @@ -9,6 +9,11 @@ one : "1 min" other: "{{ .Count }} min" +- id: words + translation: + one : "mot" + other: "{{ .Count }} mots" + - id: toc translation: "Table des Matières" diff --git a/i18n/it.yaml b/i18n/it.yaml index 58de6060..ef41db4e 100644 --- a/i18n/it.yaml +++ b/i18n/it.yaml @@ -9,6 +9,11 @@ one: "1 minuto" other: "{{ .Count }} minuti" +- id: words + translation: + one : "parola" + other: "{{ .Count }} parole" + - id: toc translation: "Tabella dei Contenuti" diff --git a/i18n/nl.yaml b/i18n/nl.yaml index 63a99319..e9d06fa5 100644 --- a/i18n/nl.yaml +++ b/i18n/nl.yaml @@ -9,6 +9,11 @@ one: "1 min" other: "{{ .Count }} min" +- id: words + translation: + one : "woord" + other: "{{ .Count }} woorden" + - id: toc translation: "Inhoudsopgave" diff --git a/i18n/pt.yaml b/i18n/pt.yaml index b30e4297..f449de9c 100644 --- a/i18n/pt.yaml +++ b/i18n/pt.yaml @@ -9,6 +9,11 @@ one: "1 minuto" other: "{{ .Count }} minutos" +- id: words + translation: + one : "palavra" + other: "{{ .Count }} palavras" + - id: toc translation: "Conteúdo" diff --git a/layouts/partials/post_meta.html b/layouts/partials/post_meta.html index 9225f13a..f7134fbf 100644 --- a/layouts/partials/post_meta.html +++ b/layouts/partials/post_meta.html @@ -8,6 +8,10 @@ {{- $scratch.Add "meta" (slice (i18n "read_time" .ReadingTime | default (printf "%d min" .ReadingTime))) }} {{- end }} +{{- if (.Param "ShowWordCount") -}} +{{- $scratch.Add "meta" (slice (i18n "words" .WordCount | default (printf "%d words" .WordCount))) }} +{{- end }} + {{- with (partial "author.html" .) }} {{- $scratch.Add "meta" (slice .) }} {{- end }}