Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content collections #166

Open
jbmoelker opened this issue Sep 6, 2024 · 1 comment
Open

Content collections #166

jbmoelker opened this issue Sep 6, 2024 · 1 comment

Comments

@jbmoelker
Copy link
Member

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

  • A content editor must be able to organise pages in collections (or tags?)
  • A Collection Route must use dynamic (server-side) rendering, so that it supports pagination, filtering (incl searching) and sorting
  • A Collection Block can show items from a collection (or multiple) with filters and sorting applied and a limit on the number of items. A layout property can define its appearance
@jbmoelker
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant