Open
Conversation
6004f93 to
d098643
Compare
503ac14 to
e1a7d51
Compare
|
感觉有点进退两难,这样写没有算上可能的更新时间, 我这样改了改: <!-- 文章时效性提示 -->
<%
// 判断是否有 page.updated
// 如果有,则使用 page.updated 时间;否则使用 page.date 时间作为文章的发布时间
let useUpdated = !!page.updated; // 将 page.updated 转换成布尔值
let articleDate = useUpdated ? new Date(page.updated) : new Date(page.date); // 根据是否有 page.updated 来选择文章发布时间
let interval = parseInt(Date.now() - articleDate);
%>
<% 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>
<% if (useUpdated) { %>
<p><%- __('post.outdate.content_updated', parseInt(interval / 86400000)) %></p>
<% } else { %>
<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>
<% if (useUpdated) { %>
<p><%- __('post.outdate.content_updated', parseInt(interval / 86400000)) %></p>
<% } else { %>
<p><%- __('post.outdate.content', parseInt(interval / 86400000)) %></p>
<% } %>
</div>
<% } %>
<% } %>不知道改过后搭配手动定义文章更新时间怎么样,😂 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
总览
该修改涉及以下方面:
功能点
“文章时效性”提示
效果
配置
功能点详述
功能使用
post.outdate配置“文章时效性”提示,开启后若文章发布日期位于warning_day与error_day之间,则显示警告note样式,若大于error_day则显示错误样式,文案如:这是一篇发布于1000天前的文章,部分信息可能已发生改变,请注意甄别。修复点
修复了 #1051