From 9b11070dd473ce51b4cb5f117b7816f83d010069 Mon Sep 17 00:00:00 2001 From: wait4xx Date: Thu, 5 Nov 2026 19:20:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(archives):=20=E7=BD=AE=E9=A1=B6=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E4=B8=8D=E5=86=8D=E6=8A=8A=E6=95=B4=E6=9C=88=E6=8B=BD?= =?UTF-8?q?=E5=88=B0=E9=A1=B6=E9=83=A8=E2=80=94=E2=80=94=E7=BD=AE=E9=A1=B6?= =?UTF-8?q?=E6=B5=AE=E5=87=BA=E5=88=86=E7=BB=84=E6=B5=81=E8=87=AA=E6=88=90?= =?UTF-8?q?=E9=A6=96=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户实测:某月有一篇置顶时,该月全部文章跟着上浮。根因:sortPosts 置顶优先后,年/月分组按顺次建桶——置顶文章让所在月提前建桶到顶部。 修复:置顶文章单独渲染为分组流之前的一节(带徽标与计数),年/月分组 只对非置顶文章按自然时序建桶,月份各归各位。 验证: pnpm astro build exit 0;产物断言分组头顺序=置顶,2026-11,2026-04,2026-03,2026-02 且置顶文仅出现一次;E2E 61/61 Spec: none (用户实测报告的排序分组 bug 紧急修复) Co-authored-by: GLM-5.3 --- src/components/PostList.astro | 67 ++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/components/PostList.astro b/src/components/PostList.astro index 50f39f6..f808971 100644 --- a/src/components/PostList.astro +++ b/src/components/PostList.astro @@ -33,8 +33,13 @@ const TRACK_LABEL: Record = { }; const hrefOf = (id: string) => (locale === 'en' ? `/en/archives/${id}/` : `/archives/${id}/`); +// 置顶浮出分组流(2026-11-05 用户实测修复):置顶文章若留在分组流里, +// 它所在月会因「顺次建桶」被提前建到顶部,整月文章跟着上浮—— +// 所以置顶单独一节渲染在年/月分组之前,分组只对非置顶文章按自然时序建桶。 +const pinned = visible.filter((p) => p.data.pinned); +const flow = visible.filter((p) => !p.data.pinned); const byYear = new Map[]>(); -for (const post of visible) { +for (const post of flow) { const year = post.data.pubDate.getUTCFullYear(); const bucket = byYear.get(year); if (bucket) bucket.push(post); @@ -107,6 +112,37 @@ const byMonth = (list: CollectionEntry<'posts'>[]) => { ) : fold ? (
+ {pinned.length > 0 && ( +
+

+ {t('pinned_label', locale)} + · {pinned.length} {units} +

+