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.
This commit is contained in:
@@ -34,5 +34,8 @@ export const fetchNotes = async (): Promise<Note[]> => {
|
|||||||
limit: 50,
|
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,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user