Files
ipal-kit/dist/modules/content/getArchiveEntries.d.ts
T
2026-08-03 12:24:28 +02:00

40 lines
1.5 KiB
TypeScript

import type { BasePayload } from 'payload';
export type ArchiveEntries<T = Record<string, unknown>> = {
docs: T[];
hasNextPage: boolean;
hasPrevPage: boolean;
/** 1-based. */
page: number;
totalDocs: number;
totalPages: number;
};
type GetArchiveEntriesArgs = {
/** Collection to list, e.g. 'posts'. */
collection: string;
/** Relationship depth. Defaults to 1 — enough for a cover image. */
depth?: number;
locale: string;
/** 1-based. Values below 1 are clamped. */
page?: number;
payload: BasePayload;
/** Defaults to 10. */
perPage?: number;
/** Payload sort string. Defaults to newest first. */
sort?: string;
/** Extra constraints merged into the query, e.g. { category: { equals: id } }. */
where?: Record<string, unknown>;
};
/**
* Fetches one page of a collection's entries for an archive listing.
*
* Only published documents are returned when the collection has drafts enabled;
* Payload's `where` on `_status` is left to the caller, since a collection
* without drafts has no such field.
*
* Returns pagination facts rather than markup — the listing itself belongs to
* the client (as a block on the archive page, most likely), because how a list
* of posts should look isn't something a plugin can decide.
*/
export declare function getArchiveEntries<T = Record<string, unknown>>({ collection, depth, locale, page, payload, perPage, sort, where, }: GetArchiveEntriesArgs): Promise<ArchiveEntries<T>>;
export {};