add dist
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
import type { BasePayload } from 'payload';
|
||||
import type { ContentOption } from './types.js';
|
||||
export type ResolvedRoute =
|
||||
/** Locale root — the page assigned as Homepage in System Pages. */
|
||||
{
|
||||
/** The archive page this entry lives under — its slug is the URL prefix. */
|
||||
archive: Record<string, unknown>;
|
||||
collection: string;
|
||||
doc: Record<string, unknown>;
|
||||
type: 'entry';
|
||||
}
|
||||
/** An ordinary page. */
|
||||
| {
|
||||
collection: string;
|
||||
doc: Record<string, unknown>;
|
||||
/** 1-based, from ?page=. */
|
||||
page: number;
|
||||
perPage: number;
|
||||
type: 'archive';
|
||||
}
|
||||
/** A collection's archive page, e.g. /pl/artykuly. */
|
||||
| {
|
||||
doc: Record<string, unknown>;
|
||||
type: 'home';
|
||||
}
|
||||
/** A single entry, e.g. /pl/artykuly/moj-post. */
|
||||
| {
|
||||
doc: Record<string, unknown>;
|
||||
type: 'page';
|
||||
};
|
||||
type ResolveRouteArgs = {
|
||||
content?: ContentOption;
|
||||
locale: string;
|
||||
/** Page number from the query string (?page=2). Defaults to 1. */
|
||||
page?: number;
|
||||
/** Client's Pages collection slug. Defaults to 'pages'. */
|
||||
pagesSlug?: string;
|
||||
payload: BasePayload;
|
||||
/** Route segments after the locale, e.g. ['artykuly', 'moj-post']. */
|
||||
segments?: string[];
|
||||
/** SiteSettings global slug. Defaults to 'site-settings'. */
|
||||
settingsSlug?: string;
|
||||
};
|
||||
/**
|
||||
* Works out what a URL points at: the home page, an ordinary page, a
|
||||
* collection's archive, or a single entry.
|
||||
*
|
||||
* Routing only. An archive result says which collection to list and on which
|
||||
* page, but doesn't fetch the entries — that's `getArchiveEntries`, called by
|
||||
* whoever actually needs them. Keeping the two apart means listing changes
|
||||
* (sorting, filtering, pagination) never touch routing rules, and metadata
|
||||
* generation doesn't pay for a query it would discard.
|
||||
*
|
||||
* The trick is that archive prefixes aren't configured anywhere — they're the
|
||||
* slug of whichever page an editor assigned as that collection's archive. So
|
||||
* /pl/artykuly and /en/articles come from one assignment, and renaming the page
|
||||
* moves the whole section.
|
||||
*
|
||||
* Resolution order matters: a first segment matching an archive's slug wins
|
||||
* over an ordinary page of the same name, because an archive *is* a page and
|
||||
* would otherwise shadow its own entries.
|
||||
*
|
||||
* Depth beyond {archive}/{entry} isn't supported — categories in the path would
|
||||
* make canonical and hreflang ambiguous (the same entry reachable under several
|
||||
* URLs).
|
||||
*/
|
||||
export declare function resolveRoute({ content, locale, page, pagesSlug, payload, segments, settingsSlug, }: ResolveRouteArgs): Promise<null | ResolvedRoute>;
|
||||
export {};
|
||||
Reference in New Issue
Block a user