--- import { getCollection, type CollectionEntry } from 'astro:content'; import BaseLayout from '../layouts/BaseLayout.astro'; import CatCard from '../components/CatCard.astro'; export interface Props { cats: CollectionEntry<'cats'>[]; pageNums: number[]; } export async function getStaticPaths() { const NUM_CATS_PER_PAGE = 18; 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); return pageNums.map((num) => ({ params: { page: num === 1 ? undefined : num.toString() }, props: { cats: allCats.slice( NUM_CATS_PER_PAGE * (num - 1), NUM_CATS_PER_PAGE * num ), pageNums } })); } const { page } = Astro.params; const { cats, pageNums } = Astro.props; const currentPageNum = Number(page || '1'); --- { cats.map((cat) => ( )) } { pageNums.map((num) => ( {num} )) }