From b2b05cc29e2028688db924ff3043c0de60654e65 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Thu, 5 May 2022 21:29:17 -0400 Subject: [PATCH] Added read time to posts that'll take longer than a minute to read --- assets/css/style.css | 2 +- layouts/blog/single.html | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/assets/css/style.css b/assets/css/style.css index 159fbc7..16b801d 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -236,4 +236,4 @@ nav li { #webmentions img { max-height: 1.2em; margin-right: -1ex; } -.date-updated { margin-top: -8px; } +.date-updated { margin-top: -18px; } diff --git a/layouts/blog/single.html b/layouts/blog/single.html index d76c2ee..d2cb070 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -15,6 +15,14 @@ {{- end }} {{ end }} {{ end }} + {{ $readTime := mul (div (countwords .Content) 220.0) 60 }} + {{ if gt $readTime 60 }} +

+ Reading Time: + {{ math.Floor (div $readTime 60) }} minutes + and {{ mod $readTime 60 }} seconds. +

+ {{ end }}