Open jbmoelker opened 2 months ago
Collection routes can take advantage of Astro's built-in pagination feature:
---
// pages/collections/[slug]/[page].astro
export async function getStaticPaths({ paginate }) {
const records = await datocmsCollection(/* ... */); // filter on `slug`
return paginate(records, { pageSize: 10 });
}
// All paginated data is passed on the "page" prop
const records = Astro.props.page.data; // subset of all records, based on pageSize above
const { total, start, end, currentPage, ...andMoreProps } = Astro.props.page;
* I now see nested pagination requires a bit more work in getStaticPaths
as it should return all paths for all slug
collections.
As a website visitor, I want content pages organised in collections, so I can easily find similar / related content