From 423672c09f09596f7e986141a9b22b5585ff09d5 Mon Sep 17 00:00:00 2001 From: BernatBC Date: Sun, 30 Jul 2023 22:14:40 +0200 Subject: [PATCH] Add reading time --- exampleSite/config.yaml | 1 + layouts/_default/single.html | 2 +- layouts/partials/cards/post.html | 2 +- layouts/partials/cards/recent-post.html | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index b39a535..ca2d6a9 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -265,6 +265,7 @@ params: # options doc: https://github.com/sampotts/plyr#options # fullscreen: true + # Enable reading time support in post cards and in post pages readingTime: enable: true diff --git a/layouts/_default/single.html b/layouts/_default/single.html index b215fdf..a5ce0ca 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -39,7 +39,7 @@
Author Image
{{ partial "helpers/get-author-name.html" . }}
-

{{ .Page.Date | time.Format ":date_full" }}{{ if site.Params.features.readingTime }} | {{ .ReadingTime }} minute{{ if (ne .ReadingTime 1) }}s{{ end }}{{end}}

+

{{ .Page.Date | time.Format ":date_full" }}{{ if site.Params.features.readingTime }} | {{ .ReadingTime }} minute{{ if (ne .ReadingTime 1) }}s{{ end }}{{ end }}

diff --git a/layouts/partials/cards/post.html b/layouts/partials/cards/post.html index 8facc41..e313d02 100644 --- a/layouts/partials/cards/post.html +++ b/layouts/partials/cards/post.html @@ -19,7 +19,7 @@
{{ end }} - {{ .Date.Format "January 2, 2006" }}{{ if site.Params.features.readingTime }} | {{ .ReadingTime }} minute{{ if (ne .ReadingTime 1) }}s{{ end }}{{end}} + {{ .Date.Format "January 2, 2006" }}{{ if site.Params.features.readingTime }} | {{ .ReadingTime }} minute{{ if (ne .ReadingTime 1) }}s{{ end }}{{ end }} {{ end }} - {{ .Date.Format "January 2, 2006" }}{{ if site.Params.features.readingTime }} | {{ .ReadingTime }} minute{{ if (ne .ReadingTime 1) }}s{{ end }}{{end}} + {{ .Date.Format "January 2, 2006" }}{{ if site.Params.features.readingTime }} | {{ .ReadingTime }} minute{{ if (ne .ReadingTime 1) }}s{{ end }}{{ end }} {{ i18n "read" }}