diff --git a/README.en.md b/README.en.md index 9c5287f..4476b31 100644 --- a/README.en.md +++ b/README.en.md @@ -561,6 +561,17 @@ quicklink: ignores: [] # Ignore the specified link, only support string ``` +#### outdate warning (v0.2.4+) + +Disabled by default + +```yaml +outdate: + enable: false + daysAgo: 180 # The number of days after which the article is considered outdated + message: 本文最后更新于 {time},请注意文中内容可能已经发生变化。 +``` +
Vendor diff --git a/README.md b/README.md index ca6f557..8adc345 100644 --- a/README.md +++ b/README.md @@ -559,6 +559,16 @@ content: license: # true | false 版权卡片展示协议? ``` +#### 过期提醒(v0.2.4+) + +默认关闭 +```yml +outdate: + enable: false + daysAgo: 180 # 多少天前的文章算过期 + message: 本文最后更新于 {time},请注意文中内容可能已经发生变化。 +``` +
diff --git a/_config.yml b/_config.yml index f06935e..6fc152a 100644 --- a/_config.yml +++ b/_config.yml @@ -278,6 +278,11 @@ live2d: reimu_cursor: true +outdate: + enable: false + daysAgo: 180 # The number of days after which the article is considered outdated + message: 本文最后更新于 {time},请注意文中内容可能已经发生变化。 + icon_font: 4552607_tq6stt6tcg # Dependent cdn links diff --git a/layout/_partial/after-footer.ejs b/layout/_partial/after-footer.ejs index e574061..008d423 100644 --- a/layout/_partial/after-footer.ejs +++ b/layout/_partial/after-footer.ejs @@ -334,6 +334,7 @@ <%- copyright() %> +<%- outdate() %> <% if (theme.footer.busuanzi) { %> <%- js({src: vendorCdn(theme.vendor.js.busuanzi)[0], async: true}) %> diff --git a/layout/_partial/article.ejs b/layout/_partial/article.ejs index 0bcbe03..fdd1d74 100644 --- a/layout/_partial/article.ejs +++ b/layout/_partial/article.ejs @@ -7,6 +7,9 @@
<%- partial('post/gallery') %>
+ <% if (theme.outdate.enable) { %> + + <% } %> <% if (post.excerpt && index) { %> <%- post.excerpt %> <% if (theme.excerpt_link) { %> diff --git a/layout/_partial/post/date.ejs b/layout/_partial/post/date.ejs index 71f88e0..5417811 100644 --- a/layout/_partial/post/date.ejs +++ b/layout/_partial/post/date.ejs @@ -1,5 +1,6 @@ diff --git a/scripts/helper/config.js b/scripts/helper/config.js index 35f76c8..0a6b8cf 100644 --- a/scripts/helper/config.js +++ b/scripts/helper/config.js @@ -4,6 +4,7 @@ hexo.extend.helper.register("themeConfig", () => { const { config } = hexo.theme; const icon_font = config.icon_font; const clipboard_tips = config.clipboard; + const outdate = config.outdate; const _global = []; if (icon_font) { _global.push(`window.icon_font = '${icon_font}';`); @@ -14,6 +15,9 @@ hexo.extend.helper.register("themeConfig", () => { if (config.service_worker.enable) { _global.push(`window.swPath = '${url_for.call(hexo, "/sw.js")}';`); } + if (outdate.enable) { + _global.push(`window.outdate = ${JSON.stringify(outdate)};`); + } return ` `; diff --git a/scripts/helper/outdate.js b/scripts/helper/outdate.js new file mode 100644 index 0000000..adc1fd1 --- /dev/null +++ b/scripts/helper/outdate.js @@ -0,0 +1,26 @@ +hexo.extend.helper.register("outdate", () => { + const { config } = hexo.theme; + if (config.outdate?.enable) { + return ` +`; + } + return ""; +}); \ No newline at end of file