-
Notifications
You must be signed in to change notification settings - Fork 732
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(post): add out-of-date content warning (#68)
- Loading branch information
Showing
13 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,15 @@ copyright = "" # default: author.name ↓ # 默认为下面配 | |
gitmentCSS = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/style/default.min.css" crossorigin="anonymous">' | ||
gitalkJS = '<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gitalk.min.js" integrity="sha256-DcjhdbufsHMHflFjZtKNFnPKOAL2ybOxGcPOR4MtnJg=" crossorigin="anonymous"></script>' | ||
gitalkCSS = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/gitalk.css" integrity="sha256-rJVe5uyYRXdLM+Kkoj7JtN+9qI0bZTxkYTaNWODpg7U=" crossorigin="anonymous">' | ||
timeagoJS = '<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/timeago.min.js" integrity="sha256-jwCP0NAdCBloaIWTWHmW4i3snUNMHUNO+jr9rYd2iOI=" crossorigin="anonymous"></script>' | ||
timeagoLocalesJS = '<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/timeago.locales.min.js" integrity="sha256-ZwofwC1Lf/faQCzN7nZtfijVV6hSwxjQMwXL4gn9qU8=" crossorigin="anonymous"></script>' | ||
|
||
# Display a message at the beginning of an article to warn the readers that it's content may be outdated. | ||
# 在文章开头显示提示信息,提醒读者文章内容可能过时。 | ||
[params.outdatedInfoWarning] | ||
enable = false | ||
hint = 30 # Display hint if the last modified time is more than these days ago. # 如果文章最后更新于这天数之前,显示提醒 | ||
warn = 180 # Display warning if the last modified time is more than these days ago. # 如果文章最后更新于这天数之前,显示警告 | ||
|
||
[params.gitment] # Gitment is a comment system based on GitHub issues. see https://github.com/imsun/gitment | ||
owner = "" # Your GitHub ID | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{{- if or .Params.enableOutdatedInfoWarning (and .Site.Params.outdatedInfoWarning.enable (ne .Params.enableOutdatedInfoWarning false)) }} | ||
{{- $daysAgo := div (sub now.Unix .Lastmod.Unix) 86400 }} | ||
{{- $hintThreshold := .Site.Params.outdatedInfoWarning.hint | default 30 }} | ||
{{- $warnThreshold := .Site.Params.outdatedInfoWarning.warn | default 180 }} | ||
|
||
{{- $updateTime := .Lastmod }} | ||
{{- if .GitInfo }} | ||
{{- if lt .GitInfo.AuthorDate.Unix .Lastmod.Unix }} | ||
{{- $updateTime := .GitInfo.AuthorDate }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{- if gt $daysAgo $hintThreshold }} | ||
<div class="post-outdated"> | ||
{{- if gt $daysAgo $warnThreshold }} | ||
<div class="warn"> | ||
{{- else }} | ||
<div class="hint"> | ||
{{- end }} | ||
<p>{{ T "outdatedInfoWarningBefore" -}} | ||
<span class="timeago" datetime="{{ dateFormat "2006-01-02T15:04:05" $updateTime }}" title="{{ dateFormat "January 2, 2006" $updateTime }}"> | ||
{{- dateFormat "January 2, 2006" $updateTime -}} | ||
</span>{{ T "outdatedInfoWarningAfter" -}} | ||
</p> | ||
</div> | ||
</div> | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.post-outdated { | ||
.hint { | ||
position: relative; | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
padding: 5px 10px; | ||
border-left: 4px solid rgb(66, 172, 243); | ||
background-color: rgb(239, 245, 255); | ||
border-color: rgb(66, 172, 243); | ||
} | ||
|
||
.warn { | ||
position: relative; | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
padding: 5px 10px; | ||
border-left: 4px solid #f9cf63; | ||
background-color: #ffffc0; | ||
border-color: #f9cf63; | ||
} | ||
} | ||
|
||
|
||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.