mirror of
https://github.com/afoim/fuwari.git
synced 2026-01-31 00:53:19 +08:00
feat: 为文章发布时间添加精确到秒的时间戳
修改文章发布时间格式,从仅日期改为包含时分秒的完整时间戳 更新文章排序逻辑和新建文章脚本以支持精确时间排序
This commit is contained in:
@@ -8,8 +8,11 @@ function getDate() {
|
||||
const year = today.getFullYear()
|
||||
const month = String(today.getMonth() + 1).padStart(2, "0")
|
||||
const day = String(today.getDate()).padStart(2, "0")
|
||||
const hours = String(today.getHours()).padStart(2, "0")
|
||||
const minutes = String(today.getMinutes()).padStart(2, "0")
|
||||
const seconds = String(today.getSeconds()).padStart(2, "0")
|
||||
|
||||
return `${year}-${month}-${day}`
|
||||
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: 有自己的开源项目?来申请Netlify的Open Source计划!
|
||||
published: 2025-08-09
|
||||
published: 2025-08-09T00:00:01
|
||||
description: '昨天在乱翻Netlify的网站,突然发现了一个开源计划的申请入口,故申请,没想到今天就通过了😋'
|
||||
image: '../assets/images/2025-08-09-05-14-11-image.png'
|
||||
tags: [Netlify]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: 利用Netlify WebHook来实时提醒你的订阅者博客文章更新
|
||||
published: 2025-08-09
|
||||
published: 2025-08-09T00:01:00
|
||||
description: '早期提过使用Github WebHook来做到这件事,今天偶然发现了Netlify也可以做到同样的事情'
|
||||
image: '../assets/images/2025-08-09-23-03-37-image.png'
|
||||
tags: [Netlify]
|
||||
|
||||
@@ -11,7 +11,7 @@ export async function getSortedPosts() {
|
||||
if (a.data.pinned !== b.data.pinned) {
|
||||
return a.data.pinned ? -1 : 1;
|
||||
}
|
||||
// 都是置顶或都不是置顶,按发布日期排序
|
||||
// 都是置顶或都不是置顶,按发布日期时间排序(包含小时分钟秒)
|
||||
const dateA = new Date(a.data.published);
|
||||
const dateB = new Date(b.data.published);
|
||||
return dateA > dateB ? -1 : 1;
|
||||
|
||||
Reference in New Issue
Block a user