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

62 lines
2.2 KiB
TypeScript

import type { BasePayload } from 'payload';
import type { ContentOption } from '../content/index.js';
import type { I18nConfig } from '../i18n/index.js';
/**
* One sitemap entry, shaped for Next's `app/sitemap.ts`.
*
* `alternates.languages` is the important part for a multilingual site: Next
* renders it as `<xhtml:link rel="alternate" hreflang=…>` per URL, which is
* exactly what Google uses to connect language versions. A sitemap without it
* is the common, weaker kind.
*/
export type SitemapEntry = {
alternates?: {
languages: Record<string, string>;
};
changeFrequency?: 'always' | 'daily' | 'hourly' | 'monthly' | 'never' | 'weekly' | 'yearly';
lastModified?: Date | string;
priority?: number;
url: string;
};
type BuildSitemapArgs = {
/** Absolute origin, e.g. 'https://example.com'. Required for valid sitemap URLs. */
baseUrl: string;
changeFrequency?: SitemapEntry['changeFrequency'];
config: I18nConfig;
/** Archive-backed collections, same value as the plugin option. */
content?: ContentOption;
/**
* Slug of the page that is the site root (collapses to /{locale}).
* Read from System Pages when omitted.
*/
homeSlug?: string;
/** Pages collection slug. Defaults to 'pages'. */
pagesSlug?: string;
payload: BasePayload;
/** SiteSettings global slug. Defaults to 'site-settings'. */
settingsSlug?: string;
};
/**
* Collects every public URL — pages and archive entries — as sitemap entries
* with per-URL hreflang and lastmod.
*
* Reuses the same path/hreflang builders as page metadata, so the sitemap can't
* drift from what the pages actually render (a classic source of sitemap bugs:
* a URL listed one way and served another). Drafts and noindex documents are
* omitted.
*
* ```ts
* // app/sitemap.ts
* export default async function sitemap() {
* return buildSitemapEntries({
* payload: await getPayload({ config }),
* config: i18nConfig,
* baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!,
* content: contentConfig,
* })
* }
* ```
*/
export declare function buildSitemapEntries({ baseUrl, changeFrequency, config, content, homeSlug, pagesSlug, payload, settingsSlug, }: BuildSitemapArgs): Promise<SitemapEntry[]>;
export {};