Since 0.23.0
getPaginatedEntries
Read one page of a collection, with the totals to link the others.
Returns one page of the selected view, 1-indexed, with the page count and total. Use it for listings too long to render at once.
const PER_PAGE = 24;
export async function generateStaticParams() {
const { pageCount } = await postCollection.getPaginatedEntries(1, {
view: "listing",
perPage: PER_PAGE,
});
return Array.from({ length: pageCount }, (_, i) => ({ page: `${i + 1}` }));
}
export default async function PostsPage({ params }: PageProps) {
const { page } = await params;
const { entries, pageCount } = await postCollection.getPaginatedEntries(
Number(page),
{ view: "listing", perPage: PER_PAGE },
);
// Render entries, and links to pages 1 to pageCount.
}
Signature
collection.getPaginatedEntries(
page: number,
options: { view?: ViewName; perPage: number },
): Promise<PaginatedEntries<Entry>>;
Parameters
Like getEntries, passing resolveDepth, filter, or sort throws.
Returns
Promise<PaginatedEntries<Entry>>:
Page boundaries follow the view's sort, otherwise slug order, so they're the same on every call. An empty collection has one empty page, so a listing can render its empty state.
What it reads
When the view has no filter and no sort, qino finds the page from the slugs alone. It reads, validates, and resolves only that page's files. Invalid files on other pages aren't reported, so run qino check to validate everything.
When the view filters or sorts, every entry has to be read before qino knows which entries are on the page. Each collection keeps its parsed files between calls and re-reads a file only once it changes, but each call still resolves every entry's images and relations. With incrementalEntries, it builds again only the entries whose files changed, so a repeated call costs about one stat per file, plus the view. Calls for the same view that run at the same time, such as the pages a build renders at once, share one listing. See Entry pipeline.
Throws
Collection "<directory>" (view "<name>"): page <n> is out of range, expected 1 to <pageCount>.Collection "<directory>" (view "<name>"): page must be a positive integer, got <value>.Collection "<directory>" (view "<name>"): perPage must be a positive integer, got <value>.Unknown view "<name>". Available views: <names>.- The getter option, validation, relation, and augment errors of getEntries.