Skip to content

Commit

Permalink
fix(home): fixed calculation error in how long ago the post was updated
Browse files Browse the repository at this point in the history
  • Loading branch information
XPoet committed Sep 5, 2023
1 parent 9817506 commit 7187d4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion layout/_partial/article-meta-info.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const home_tag_limit_number = theme?.home_article?.tag?.limit || 3
<div class="article-meta-info border-box">
<% if (page_type === 'home') { %>
<span class="meta-info-item border-box">
<i class="icon fas fa-history"></i>&nbsp;<span class="home-article-history" data-updated="<%= post.updated %>"><%= date(post.updated, 'YYYY-MM-DD') %></span>
<i class="icon fas fa-history"></i>&nbsp;<span class="home-article-history" data-updated="<%= post.updated %>"><%= date(post.updated, 'YYYY-MM-DD HH:mm:ss') %></span>
</span>
<% } %>
Expand Down
6 changes: 3 additions & 3 deletions source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ KEEP.initUtils = () => {
const post = document.querySelectorAll('.article-meta-info .home-article-history')
post &&
post.forEach((v) => {
const nowDate = Date.now()
const postDate = new Date(v.dataset.updated.split(' GMT')[0]).getTime()
v.innerHTML = this.getHowLongAgo(Math.floor((nowDate - postDate) / 1000))
const nowTimestamp = Date.now()
const updatedTimestamp = new Date(v.dataset.updated).getTime()
v.innerHTML = this.getHowLongAgo(Math.floor((nowTimestamp - updatedTimestamp) / 1000))
})
},

Expand Down

0 comments on commit 7187d4e

Please sign in to comment.