voorhoede / head-start

Base setup on top of headless services to help you quickly start a new website
ISC License
4 stars 0 forks source link

Content collections #166

Open jbmoelker opened 1 month ago

jbmoelker commented 1 month ago

As a website visitor, I want content pages organised in collections, so I can easily find similar / related content

jbmoelker commented 1 day 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.