From 1b98aabe370c60adbf472909d1bc5bfd9fa4904a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Sun, 3 Sep 2023 03:58:21 +0200 Subject: [PATCH] Order cats by dateAdded descendingly --- src/pages/[...page].astro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/[...page].astro b/src/pages/[...page].astro index d9976ec..f38e667 100644 --- a/src/pages/[...page].astro +++ b/src/pages/[...page].astro @@ -11,9 +11,9 @@ export interface Props { export async function getStaticPaths() { const NUM_CATS_PER_PAGE = 18; - - const [firstCat] = await getCollection('cats'); - const allCats = Array(100).fill(firstCat); + const allCats = (await getCollection('cats')).sort( + (a, b) => b.data.dateAdded.valueOf() - a.data.dateAdded.valueOf() + ); const maxPageNum = Math.ceil(allCats.length / NUM_CATS_PER_PAGE); const pageNums = [...Array(maxPageNum).keys()].map((key) => key + 1);