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

github.com/queensferryme/hugo-theme-texify.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQueensferry <queensferry.me@gmail.com>2022-04-01 12:06:11 +0300
committerQueensferry <queensferry.me@gmail.com>2022-04-01 12:06:21 +0300
commitba94670d3dc7580703f6f4c7d38965ae9923df5f (patch)
tree661508854b39c4ca53b416c160ac13eb013ac9c5
parenteee37ae644f833740e46039e4d0fb3cad8448be3 (diff)
feat: implement outdate post warning (#15)
-rw-r--r--config.toml11
-rw-r--r--layouts/_default/single.html6
-rw-r--r--static/css/single.css8
3 files changed, 23 insertions, 2 deletions
diff --git a/config.toml b/config.toml
index 509bd07..2ddbcdc 100644
--- a/config.toml
+++ b/config.toml
@@ -4,9 +4,10 @@
###################################################
baseURL = "https://texify.qufy.me" # website root path
-disqusShortname = "" # Disqus shortcode
+disqusShortname = "" # disqus shortcode
+enableGitInfo = false # retrieve last modified date from git commits
enableRobotsTXT = true # /robots.txt
-googleAnalytics = "" # Google Analytics ID
+googleAnalytics = "" # google analytics id
hasCJKLanguage = true # Chinese/Japanese/Korean
languageCode = "en" # content language
paginate = 5 # number of posts each page
@@ -74,6 +75,12 @@ toc = false # whether to enable table of contents in posts
enable = true # whether to enable math typesetting
use = "katex" # katex or mathjax
+[params.outdated]
+enable = true # whether to display warnings for outdated posts
+limit = 1000 # days between last modified time and outdated time
+# warning to be displayed
+warning = "⚠️ It has been <i>%d</i> days since the last update, the content of the article may be outdated."
+
# https://utteranc.es
[params.utterances]
enable = false
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index eb37df4..b4b496a 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -9,6 +9,12 @@
{{ .Content }}
</article>
{{ else }}
+ {{ if .Site.Params.outdated.enable }}
+ {{ $days := div (sub now.Unix .Lastmod.Unix) 86400 }}
+ {{ if gt $days .Site.Params.outdated.limit }}
+ <div class="warning">{{ printf .Site.Params.outdated.warning $days | safeHTML }}</div>
+ {{ end }}
+ {{ end }}
<h1>{{ .Title }}</h1>
{{ if ne .Params.tags nil }}
<div>
diff --git a/static/css/single.css b/static/css/single.css
index f2a90a3..0110818 100644
--- a/static/css/single.css
+++ b/static/css/single.css
@@ -6,6 +6,14 @@
padding-top: 1rem;
}
+#main > .warning {
+ background-color: tomato;
+ color: white;
+ font-size: 1.1rem;
+ padding: 1rem 0;
+ text-align: center;
+}
+
#main .toc {
background-color: #EEEEEE;
border: black 1px dashed;