From e8a3b0a9f4c24e5dac0f0a6b8a69c275936fa514 Mon Sep 17 00:00:00 2001 From: afoim Date: Sun, 10 Aug 2025 17:57:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=BA=E6=96=87=E7=AB=A0=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=97=B6=E9=97=B4=E6=B7=BB=E5=8A=A0=E7=B2=BE=E7=A1=AE?= =?UTF-8?q?=E5=88=B0=E7=A7=92=E7=9A=84=E6=97=B6=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改文章发布时间格式,从仅日期改为包含时分秒的完整时间戳 更新文章排序逻辑和新建文章脚本以支持精确时间排序 --- scripts/new-post.js | 5 ++++- src/content/posts/netlify-oss.md | 2 +- src/content/posts/netlify-webhook.md | 2 +- src/utils/content-utils.ts | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/new-post.js b/scripts/new-post.js index 253139020..187bfd0e7 100644 --- a/scripts/new-post.js +++ b/scripts/new-post.js @@ -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) diff --git a/src/content/posts/netlify-oss.md b/src/content/posts/netlify-oss.md index c22d6b001..7da7de6f7 100644 --- a/src/content/posts/netlify-oss.md +++ b/src/content/posts/netlify-oss.md @@ -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] diff --git a/src/content/posts/netlify-webhook.md b/src/content/posts/netlify-webhook.md index afa6a2d41..c6909251f 100644 --- a/src/content/posts/netlify-webhook.md +++ b/src/content/posts/netlify-webhook.md @@ -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] diff --git a/src/utils/content-utils.ts b/src/utils/content-utils.ts index 2964ede24..ddb904dac 100644 --- a/src/utils/content-utils.ts +++ b/src/utils/content-utils.ts @@ -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;