From 3153200eb3815ab2cda9905d148225be036eb1be Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 23 May 2026 16:52:01 +0200 Subject: [PATCH] refactor(notes): sort fetched notes by publishedAt desc Centralise ordering in fetchNotes so every consumer (homepage, /pub index, RSS feed) shares the same newest-first order. --- src/api/fetch-notes.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/fetch-notes.ts b/src/api/fetch-notes.ts index a8266f6..68659bf 100644 --- a/src/api/fetch-notes.ts +++ b/src/api/fetch-notes.ts @@ -34,5 +34,8 @@ export const fetchNotes = async (): Promise => { limit: 50, }) - return (records || []).map((record) => record.value) + const notes = (records || []).map((record) => record.value as Note) + return notes.sort((a, b) => + a.publishedAt < b.publishedAt ? 1 : a.publishedAt > b.publishedAt ? -1 : 0, + ) }