mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
✨ Feat: add article expiration reminder support (#51)
This commit is contained in:
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
|
||||
- :tada: Feat: add Twikoo comment support ([#64](https://github.com/Lruihao/FixIt/issues/64))
|
||||
- :sparkles: Style: add media style for print view ([#61](https://github.com/Lruihao/FixIt/issues/61))
|
||||
- :sparkles: Feat: add pageStyle option ([#62](https://github.com/Lruihao/FixIt/issues/62))
|
||||
- :sparkles: Feat: add article expiration reminder support ([#51](https://github.com/Lruihao/FixIt/issues/51))
|
||||
- :sparkles: Feat: add 9 newly supported social links ([#17](https://github.com/Lruihao/FixIt/issues/17))
|
||||
- :sparkles: Feat: update cell-watermark 1.0.3 and support CDN (fontFamily supported)
|
||||
- :sparkles: Feat: add Gravatar mirror site support ([#66](https://github.com/Lruihao/FixIt/pull/66)@ctj12461)
|
||||
|
||||
@@ -656,6 +656,19 @@ enableEmoji = true
|
||||
# position of TOC ("left", "right") since v0.2.13
|
||||
# 目录位置 ("left", "right") since v0.2.13
|
||||
position = "right"
|
||||
# Display a message at the beginning of an article to warn the reader that its content might be expired. since v0.2.13
|
||||
# 在文章开头显示提示信息,提醒读者文章内容可能过时。 since v0.2.13
|
||||
[params.page.expirationReminder]
|
||||
enable = true
|
||||
# Display the reminder if the last modified time is more than 90 days ago
|
||||
# 如果文章最后更新于这天数之前,显示提醒
|
||||
reminder = 90
|
||||
# Display warning if the last modified time is more than 180 days ago
|
||||
# 如果文章最后更新于这天数之前,显示警告
|
||||
warning = 180
|
||||
# If the article expires, close the comment or not
|
||||
# 如果文章到期是否关闭评论
|
||||
closeComment = false
|
||||
# Code config
|
||||
# 代码配置
|
||||
[params.page.code]
|
||||
|
||||
@@ -448,6 +448,15 @@ Please open the code block below to view the complete sample configuration :(far
|
||||
auto = true
|
||||
# {{< version 0.2.13 >}} position of TOC ("left", "right")
|
||||
position = "right"
|
||||
# {{< version 0.2.13 >}} Display a message at the beginning of an article to warn the reader that its content might be expired
|
||||
[params.page.expirationReminder]
|
||||
enable = false
|
||||
# Display the reminder if the last modified time is more than 90 days ago
|
||||
reminder = 90
|
||||
# Display warning if the last modified time is more than 180 days ago
|
||||
warning = 180
|
||||
# If the article expires, close the comment or not
|
||||
closeComment = false
|
||||
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} mathematical formulas (https://katex.org)
|
||||
[params.page.math]
|
||||
enable = true
|
||||
|
||||
@@ -459,6 +459,15 @@ hugo
|
||||
auto = true
|
||||
# {{< version 0.2.13 >}} 目录位置 ("left", "right")
|
||||
position = "right"
|
||||
# {{< version 0.2.13 >}} 在文章开头显示提示信息,提醒读者文章内容可能过时
|
||||
[params.page.expirationReminder]
|
||||
enable = false
|
||||
# 如果文章最后更新于这天数之前,显示提醒
|
||||
reminder = 90
|
||||
# 如果文章最后更新于这天数之前,显示警告
|
||||
warning = 180
|
||||
# 如果文章到期是否关闭评论
|
||||
closeComment = false
|
||||
# {{< version 0.2.0 >}} 代码配置
|
||||
[params.page.code]
|
||||
# 是否显示代码块的复制按钮
|
||||
|
||||
@@ -145,6 +145,9 @@ other = "Home"
|
||||
|
||||
[readMore]
|
||||
other = "Read More"
|
||||
|
||||
[expirationReminder]
|
||||
other = "This article was last updated on {{ .Date }}, the content may be out of date."
|
||||
# === posts/single.html ===
|
||||
|
||||
# === 404.html ===
|
||||
|
||||
@@ -150,6 +150,9 @@ other = "主页"
|
||||
|
||||
[readMore]
|
||||
other = "阅读全文"
|
||||
|
||||
[expirationReminder]
|
||||
other = "本文最后更新于 {{ .Date }},文中内容可能已过时。"
|
||||
# === posts/single.html ===
|
||||
|
||||
# === 404.html ===
|
||||
|
||||
@@ -150,6 +150,9 @@ other = "主頁"
|
||||
|
||||
[readMore]
|
||||
other = "閱讀全文"
|
||||
|
||||
[expirationReminder]
|
||||
other = "本文最後更新於 {{ .Date }},文中內容可能已過時。"
|
||||
# === posts/single.html ===
|
||||
|
||||
# === 404.html ===
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
{{- $expirationReminder := $params.expirationReminder | default dict -}}
|
||||
|
||||
{{- if $expirationReminder.enable -}}
|
||||
{{- $daysAgo := div (sub now.Unix .Lastmod.Unix) 86400 }}
|
||||
{{- $reminderThreshold := $expirationReminder.reminder | default 90 }}
|
||||
{{- $warningThreshold := $expirationReminder.warning | default 180 }}
|
||||
{{- $updateTime := .Lastmod }}
|
||||
|
||||
{{- if gt $daysAgo $reminderThreshold -}}
|
||||
{{- $type := "note" -}}
|
||||
{{- $icon := "fa-pencil-alt" -}}
|
||||
{{- if gt $daysAgo $warningThreshold -}}
|
||||
{{- $type = "warning" -}}
|
||||
{{- $icon = "fa-exclamation-triangle" -}}
|
||||
{{- /* If the article expires, close the comment or not */ -}}
|
||||
{{- if $expirationReminder.closeComment -}}
|
||||
{{- .Scratch.Set "comment" dict -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
<div class="details admonition {{ $type }} open">
|
||||
<div class="details-summary admonition-title">
|
||||
<i class="icon fas {{ $icon }} fa-fw"></i>{{ T $type }}<i class="details-icon fas fa-angle-right fa-fw"></i>
|
||||
</div>
|
||||
<div class="details-content">
|
||||
<div class="admonition-content">
|
||||
{{- with .Site.Params.dateformat | default "2006-01-02" | $updateTime.Format -}}
|
||||
{{- dict "Date" . | T "expirationReminder" -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -95,6 +95,8 @@
|
||||
|
||||
{{- /* Content */ -}}
|
||||
<div class="content" id="content">
|
||||
{{- /* Expiration Reminder */ -}}
|
||||
{{- partial "single/expirationReminder.html" . -}}
|
||||
{{- dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user