From f0397730e63ea446cfe31c28ecc6fbcfe2bfe6f1 Mon Sep 17 00:00:00 2001 From: SepComet <202308010230@stu.csust.edu.cn> Date: Thu, 7 May 2026 09:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E9=A1=B5=E9=9D=A2=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=B8=BA=E4=B8=9C=E5=85=AB=E5=8C=BA=E5=B9=B6=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=B4=BB=E5=8A=A8=E6=9D=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GiteaActivity.astro | 2 +- src/components/LogCard.astro | 8 +++--- src/pages/logs/[slug].astro | 7 ++---- src/utils/datetime.ts | 40 +++++++++++++++++++++++++++--- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/components/GiteaActivity.astro b/src/components/GiteaActivity.astro index 8bbe41a..2a20b52 100644 --- a/src/components/GiteaActivity.astro +++ b/src/components/GiteaActivity.astro @@ -76,7 +76,7 @@ function summarizeActivity(item: GiteaActivityData['recent'][number]) { } } -const recentActivities = activity.recent.slice(0, 3).map(summarizeActivity); +const recentActivities = activity.recent.slice(0, 4).map(summarizeActivity); const isPlaceholder = activity.source === 'placeholder'; --- diff --git a/src/components/LogCard.astro b/src/components/LogCard.astro index 90e1c92..81c11b3 100644 --- a/src/components/LogCard.astro +++ b/src/components/LogCard.astro @@ -1,4 +1,6 @@ --- +import { formatDate } from '../utils/datetime'; + interface Props { slug: string; title: string; @@ -9,11 +11,7 @@ interface Props { } const { slug, title, date, repo, summary, tags } = Astro.props; -const formattedDate = date.toLocaleDateString('zh-CN', { - year: 'numeric', - month: '2-digit', - day: '2-digit', -}); +const formattedDate = formatDate(date); ---
diff --git a/src/pages/logs/[slug].astro b/src/pages/logs/[slug].astro index 786a9aa..315ed8a 100644 --- a/src/pages/logs/[slug].astro +++ b/src/pages/logs/[slug].astro @@ -2,6 +2,7 @@ import { getCollection, render } from 'astro:content'; import Layout from '../../layouts/Layout.astro'; import { site } from '../../config'; +import { formatDate } from '../../utils/datetime'; export async function getStaticPaths() { const logs = await getCollection('logs'); @@ -14,11 +15,7 @@ export async function getStaticPaths() { const { log } = Astro.props; const { Content } = await render(log); -const formattedDate = log.data.date.toLocaleDateString('zh-CN', { - year: 'numeric', - month: '2-digit', - day: '2-digit', -}); +const formattedDate = formatDate(log.data.date); --- Date.parse(value)).filter((value) => !Number.isNaN(value)); if (timestamps.length === 0) {