From 80205a71177efe6a1a6d8084f71174e207571394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernat=20Borr=C3=A0s=20Civil?= <70479573+BernatBC@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:30:13 +0200 Subject: [PATCH] Add reading time, #679 (#784) * Add reading time * Add reading time --- exampleSite/config.yaml | 4 ++++ layouts/_default/single.html | 2 +- layouts/partials/cards/post.html | 2 +- layouts/partials/cards/recent-post.html | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index ceb7416..ca2d6a9 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -264,6 +264,10 @@ params: plyr: # options doc: https://github.com/sampotts/plyr#options # fullscreen: true + + # Enable reading time support in post cards and in post pages + readingTime: + enable: true # Provide footer configuration. diff --git a/layouts/_default/single.html b/layouts/_default/single.html index a98f180..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" }}

+

{{ .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 200cf84..e313d02 100644 --- a/layouts/partials/cards/post.html +++ b/layouts/partials/cards/post.html @@ -19,7 +19,7 @@
{{ end }} - {{ .Date.Format "January 2, 2006" }} + {{ .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" }} + {{ .Date.Format "January 2, 2006" }}{{ if site.Params.features.readingTime }} | {{ .ReadingTime }} minute{{ if (ne .ReadingTime 1) }}s{{ end }}{{ end }} {{ i18n "read" }}