feat: posts-first in index
This commit is contained in:
parent
a3b63f9c85
commit
44c3c0573c
2 changed files with 12 additions and 4 deletions
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue