Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加“文章时效性”提示 #1052

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,17 @@ post:
# Options: busuanzi | leancloud
source: "busuanzi"

# 在文章开头显示文章过期/时效提示
# Display expiration/expiration notification at the beginning of the article
outdate:
enable: false
# 文章时效提示使用警告样式的天数,超过此天数显示警告样式的note
# The number of days for the article's timeliness prompt to use warning style, exceeding this number of days will display warning style notes
warning_day: 200
# 文章时效提示使用错误样式的天数,超过此天数显示错误样式的note
# The number of days for the article's timeliness prompt to use the wrong style. If this number is exceeded, a note with the wrong style will be displayed
error_day: 400

# 在文章开头显示文章更新时间,该时间默认是 md 文件更新时间,可通过 front-matter 中 `updated` 手动指定(和 date 一样格式)
# Update date is displayed at the beginning of the post. The default date is the update date of the md file, which can be manually specified by `updated` in front-matter (same format as date)
updated:
Expand Down
3 changes: 3 additions & 0 deletions languages/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: 'Vorheriger'
next_post: 'Nächster'
updated: 'Geändert am %s'
outdate:
title: 'Rechtzeitigkeitserinnerung für Artikel'
content: 'Dies ist ein Artikel, der vor %s Tagen veröffentlicht wurde, und einige Informationen könnten sich geändert haben.'
meta:
wordcount: '%s wörter'
min2read: '%s minuten'
Expand Down
3 changes: 3 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: 'Previous'
next_post: 'Next'
updated: 'Last updated on %s'
outdate:
title: 'Timeliness reminder for articles'
content: 'This is an article published %s days ago, and some information may have changed. Please pay attention to discernment.'
meta:
wordcount: '%s words'
min2read: '%s mins'
Expand Down
3 changes: 3 additions & 0 deletions languages/eo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: 'Antaŭa afiŝo'
next_post: 'Sekva afiŝo'
updated: 'Aktualizita: %s'
outdate:
title: '@ info: whatsthis'
content: 'Tio estas artiklo publikigita antaŭ la %s tagoj, kaj kelkaj informoj eble ŝan ĝiĝis. Bonvolu atenti la malprudentecon.'
meta:
wordcount: '%s vortoj'
min2read: '%s minutoj'
Expand Down
3 changes: 3 additions & 0 deletions languages/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: 'Anterior'
next_post: 'Siguiente'
updated: 'Última actualización el %s'
outdate:
title: 'Consejos de puntualidad del artículo'
content: 'Este es un artículo publicado hace %s días, y parte de la información puede haber cambiado, preste atención a la selección.'
meta:
wordcount: '%s palabras'
min2read: '%s minutos'
Expand Down
3 changes: 3 additions & 0 deletions languages/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: '前の記事'
next_post: '次の記事'
updated: '最終更新日:%s'
outdate:
title: '記事の有効性のヒント'
content: 'これは%sに掲載される前の記事で、一部の情報が変更されている可能性がありますので、識別に注意してください。'
meta:
wordcount: '%s 単語'
min2read: '%s 分'
Expand Down
3 changes: 3 additions & 0 deletions languages/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: 'Предыдущий'
next_post: 'Следующий'
updated: 'Последнее обновление %s'
outdate:
title: 'Настройка статьи'
content: 'Это статья, опубликованная %s ранее, часть информации может измениться, обратите внимание на скрининг.'
meta:
wordcount: '%s слов'
min2read: '%s минут'
Expand Down
3 changes: 3 additions & 0 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: '上一篇'
next_post: '下一篇'
updated: '本文最后更新于 %s'
outdate:
title: '文章时效性提示'
content: '这是一篇发布于%s天前的文章,部分信息可能已发生改变,请注意甄别。'
meta:
wordcount: '%s 字'
min2read: '%s 分钟'
Expand Down
3 changes: 3 additions & 0 deletions languages/zh-HK.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: '上一篇'
next_post: '下一篇'
updated: '本文最後更新於:%s'
outdate:
title: '文章時效性提示'
content: '這是一篇發佈於%s天前的文章,部分資訊可能已發生改變,請注意甄別。'
meta:
wordcount: '%s 字'
min2read: '%s 分鐘'
Expand Down
3 changes: 3 additions & 0 deletions languages/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ post:
prev_post: '上一篇'
next_post: '下一篇'
updated: '本文最後更新於:%s'
outdate:
title: '文章時效性提示'
content: '這是一篇發佈於%s天前的文章,部分資訊可能已發生改變,請注意甄別。'
meta:
wordcount: '%s 字'
min2read: '%s 分鐘'
Expand Down
14 changes: 14 additions & 0 deletions layout/post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ page.banner_mask_alpha = page.banner_mask_alpha || theme.post.banner_mask_alpha
<div id="board">
<article class="post-content mx-auto">
<h1 id="seo-header"><%= page.subtitle || page.title %></h1>
<% let interval = parseInt(Date.now() - new Date(page.date)) %>
<% if (theme.post.outdate.enable) { %>
<% if (interval > theme.post.outdate.warning_day * 3600 * 24 * 1000 && interval < theme.post.outdate.error_day * 3600 * 24 * 1000) { %>
<div class="note note-warning">
<h5><%- __('post.outdate.title') %></h5>
<p><%- __('post.outdate.content', parseInt(interval / 86400000)) %></p>
</div>
<% } else if(interval > theme.post.outdate.error_day * 3600 * 24 * 1000) { %>
<div class="note note-danger">
<h5><%- __('post.outdate.title') %></h5>
<p><%- __('post.outdate.content', parseInt(interval / 86400000)) %></p>
</div>
<% } %>
<% } %>
<% if (theme.post.updated.enable && theme.post.updated && compare_date(page.date, page.updated)) { %>
<p id="updated-time" class="note note-<%= theme.post.updated.note_class || 'info' %>" style="<%= theme.post.updated.relative ? 'display: none' : '' %>">
<% if (theme.post.updated.relative) { %>
Expand Down