mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 17:30:53 +08:00
feat: 增加 aside 最新評論部件
style: 部分css調整和html優化 improvements: 刪除pwa中的theme-color配置,默認生成meta theme-color close #340 improvements: 優化最後更新時間顯示(1小時內顯示 剛剛,1小時到24小時 顯示 xx小時前,1天到365天 顯示 xx天前,365天后直接顯示日期)
This commit is contained in:
@@ -97,12 +97,26 @@ const initJustifiedGallery = function (selector) {
|
||||
})
|
||||
}
|
||||
|
||||
const diffDate = d => {
|
||||
const diffDate = (d, more = false) => {
|
||||
const dateNow = new Date()
|
||||
const datePost = new Date(d.replace(/-/g, '/'))
|
||||
const datePost = new Date(d)
|
||||
const dateDiff = dateNow.getTime() - datePost.getTime()
|
||||
const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000))
|
||||
return dayDiff
|
||||
let result
|
||||
if (more) {
|
||||
if (dateDiff <= 3600000) { // < 1 hour
|
||||
result = GLOBAL_CONFIG.date_suffix.one_hour
|
||||
} else if (dateDiff < 3600000 * 24) { // 1 hour < x < 24 hours
|
||||
result = Math.floor(dateDiff / 3600000) + ' ' + GLOBAL_CONFIG.date_suffix.hours
|
||||
} else if (dayDiff >= 1 || dayDiff < 365) { // 1 day < x < 365 days
|
||||
result = dayDiff + ' ' + GLOBAL_CONFIG.date_suffix.day
|
||||
} else { // > 365 days
|
||||
result = d.toLocaleDateString().replace(/\//g, '-')
|
||||
}
|
||||
} else {
|
||||
result = dayDiff
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
const loadComment = (dom, callback) => {
|
||||
|
||||
Reference in New Issue
Block a user