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

github.com/monkeyWzr/hugo-theme-cactus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGo <monkeywzr@gmail.com>2021-04-20 02:18:12 +0300
committerGitHub <noreply@github.com>2021-04-20 02:18:12 +0300
commit4b422e609632ab67ceff93ed00ae9417ebb1ccb9 (patch)
tree5da28dd2332765873166db008b3fb2286828b6e7
parentcec90bd446a58b439de23b3f292f766599f4b75e (diff)
parentf031fb6c52ad09167f6e89194ce46b8113c919bd (diff)
Merge pull request #42 from switchswap/feature/read-time
Add read time to posts
-rw-r--r--exampleSite/config.toml1
-rw-r--r--layouts/posts/single.html8
-rw-r--r--static/css/style-classic.css4
-rw-r--r--static/css/style-dark.css4
-rw-r--r--static/css/style-light.css4
-rw-r--r--static/css/style-white.css4
6 files changed, 25 insertions, 0 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 65e445a..f10a3b0 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -56,6 +56,7 @@ weight = 4
# Post page settings
show_updated = false # default
+ showReadTime = false # default
[params.comments]
enabled = false # default
diff --git a/layouts/posts/single.html b/layouts/posts/single.html
index d2b6042..bbf36e5 100644
--- a/layouts/posts/single.html
+++ b/layouts/posts/single.html
@@ -30,6 +30,14 @@
(Updated: <time datetime="{{ .Lastmod }}" itemprop="dateModified">{{ .Lastmod.Format $dataFormat }}</time>)
{{ end }}
</div>
+ {{ $showReadTime := .Site.Params.showReadTime | default false }}
+ {{if $showReadTime}}
+ <div class="article-read-time">
+ <i class="far fa-clock"></i>
+ {{ $readTime := math.Round (div (countwords .Content) 220.0) }}
+ {{ $readTime }} minute read
+ </div>
+ {{ end }}
{{ if gt .Params.categories 0 }}
<div class="article-category">
<i class="fas fa-archive"></i>
diff --git a/static/css/style-classic.css b/static/css/style-classic.css
index 46715f9..85ee12c 100644
--- a/static/css/style-classic.css
+++ b/static/css/style-classic.css
@@ -1090,6 +1090,9 @@ article header .author {
letter-spacing: 0.01em;
font-weight: 700;
}
+article header .article-read-time {
+ display: inline;
+}
article header .postdate {
display: inline;
}
@@ -1207,6 +1210,7 @@ article .content .caption {
.article-category {
display: inline;
}
+ .article-read-time:before,
.article-tag:before,
.article-category:before {
content: "|";
diff --git a/static/css/style-dark.css b/static/css/style-dark.css
index 0af7609..d96e039 100644
--- a/static/css/style-dark.css
+++ b/static/css/style-dark.css
@@ -1090,6 +1090,9 @@ article header .author {
letter-spacing: 0.01em;
font-weight: 700;
}
+article header .article-read-time {
+ display: inline;
+}
article header .postdate {
display: inline;
}
@@ -1207,6 +1210,7 @@ article .content .caption {
.article-category {
display: inline;
}
+ .article-read-time:before,
.article-tag:before,
.article-category:before {
content: "|";
diff --git a/static/css/style-light.css b/static/css/style-light.css
index 2b0d90b..8a4cca5 100644
--- a/static/css/style-light.css
+++ b/static/css/style-light.css
@@ -1090,6 +1090,9 @@ article header .author {
letter-spacing: 0.01em;
font-weight: 700;
}
+article header .article-read-time {
+ display: inline;
+}
article header .postdate {
display: inline;
}
@@ -1207,6 +1210,7 @@ article .content .caption {
.article-category {
display: inline;
}
+ .article-read-time:before,
.article-tag:before,
.article-category:before {
content: "|";
diff --git a/static/css/style-white.css b/static/css/style-white.css
index 1fd9e0a..40db9e2 100644
--- a/static/css/style-white.css
+++ b/static/css/style-white.css
@@ -1106,6 +1106,9 @@
letter-spacing: 0.01em;
font-weight: 700;
}
+ article header .article-read-time {
+ display: inline;
+ }
article header .postdate {
display: inline;
}
@@ -1223,6 +1226,7 @@
.article-category {
display: inline;
}
+ .article-read-time:before,
.article-tag:before,
.article-category:before {
content: "|";