feat: posts-first in index

This commit is contained in:
Lewis Wynne 2026-01-23 19:40:41 +00:00
parent a3b63f9c85
commit 44c3c0573c
2 changed files with 12 additions and 4 deletions

View file

@ -28,8 +28,12 @@ const grouped = posts.reduce((acc, post) => {
return acc; return acc;
}, {} as Record<string, typeof posts>); }, {} as Record<string, typeof posts>);
// Sort categories alphabetically // Sort categories: "posts" first, then alphabetically
const sortedCategories = Object.keys(grouped).sort(); 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 // Sort posts within each category: pinned first, then by date descending
for (const category of sortedCategories) { for (const category of sortedCategories) {

View file

@ -12,8 +12,12 @@ const grouped = posts.reduce((acc, post) => {
return acc; return acc;
}, {} as Record<string, typeof posts>); }, {} as Record<string, typeof posts>);
// Sort categories alphabetically // Sort categories: "posts" first, then alphabetically
const sortedCategories = Object.keys(grouped).sort(); 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 // Sort posts within each category: pinned first, then by date descending
for (const category of sortedCategories) { for (const category of sortedCategories) {