Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/AmazingRise/hugo-theme-diary.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramazingrise <8315221+AmazingRise@users.noreply.github.com>2020-04-24 17:55:56 +0300
committeramazingrise <8315221+AmazingRise@users.noreply.github.com>2020-04-24 17:55:56 +0300
commita21a3b2f7bbd3631f5ac09c0114be0c5b8bcd44b (patch)
tree603d8a6d9fd3a61b214fc562a6d95e5ac5a43e45
parentac4c8941683e11eec6252143f7994195a85bddf1 (diff)
Add reading time.
-rw-r--r--layouts/_default/single.html10
1 files changed, 10 insertions, 0 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 14f7cd1..451cf78 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -37,6 +37,16 @@
&nbsp;
{{ end }}
{{ end }}
+ {{ if .Site.Params.enableReadingTime }}
+ <i class="material-icons" style="">schedule</i>
+ {{ $readTime := mul (div (countwords .Content) 220.0) 60 }}
+
+ {{ $minutes := math.Floor (div $readTime 60) }}
+ {{ $seconds := mod $readTime 60 }}
+
+ {{ $minutes }} {{ cond (eq $minutes 1) "minute" "min" }}
+ {{ $seconds }} {{ cond (eq $seconds 1) "second" "s" }}.
+ {{ end }}
</div>
</div>
</div>