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() { export async function getStaticPaths() {
const NUM_CATS_PER_PAGE = 18; const NUM_CATS_PER_PAGE = 18;
const allCats = (await getCollection('cats')).sort(
const [firstCat] = await getCollection('cats'); (a, b) => b.data.dateAdded.valueOf() - a.data.dateAdded.valueOf()
const allCats = Array(100).fill(firstCat); );
const maxPageNum = Math.ceil(allCats.length / NUM_CATS_PER_PAGE); const maxPageNum = Math.ceil(allCats.length / NUM_CATS_PER_PAGE);
const pageNums = [...Array(maxPageNum).keys()].map((key) => key + 1); const pageNums = [...Array(maxPageNum).keys()].map((key) => key + 1);