From 44c3c0573c841fd65e2b358de856274982cb452d Mon Sep 17 00:00:00 2001 From: lew Date: Fri, 23 Jan 2026 19:40:41 +0000 Subject: [PATCH] feat: posts-first in index --- apps/blog/src/pages/index.astro | 8 ++++++-- apps/blog/src/pages/md/index.astro | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/blog/src/pages/index.astro b/apps/blog/src/pages/index.astro index 845308e..1c7a0a1 100644 --- a/apps/blog/src/pages/index.astro +++ b/apps/blog/src/pages/index.astro @@ -28,8 +28,12 @@ const grouped = posts.reduce((acc, post) => { return acc; }, {} as Record); -// Sort categories alphabetically -const sortedCategories = Object.keys(grouped).sort(); +// Sort categories: "posts" first, then alphabetically +const sortedCategories = Object.keys(grouped).sort((a, b) => { + if (a === 'posts') return -1; + if (b === 'posts') return 1; + return a.localeCompare(b); +}); // Sort posts within each category: pinned first, then by date descending for (const category of sortedCategories) { diff --git a/apps/blog/src/pages/md/index.astro b/apps/blog/src/pages/md/index.astro index e3d7ad0..f918c9d 100644 --- a/apps/blog/src/pages/md/index.astro +++ b/apps/blog/src/pages/md/index.astro @@ -12,8 +12,12 @@ const grouped = posts.reduce((acc, post) => { return acc; }, {} as Record); -// Sort categories alphabetically -const sortedCategories = Object.keys(grouped).sort(); +// Sort categories: "posts" first, then alphabetically +const sortedCategories = Object.keys(grouped).sort((a, b) => { + if (a === 'posts') return -1; + if (b === 'posts') return 1; + return a.localeCompare(b); +}); // Sort posts within each category: pinned first, then by date descending for (const category of sortedCategories) {