Order cats by dateAdded descendingly

This commit is contained in:
Maciej Pędzich 2023-09-03 03:58:21 +02:00
parent 9449d528f2
commit 1b98aabe37

View File

@ -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);