Files
ipal-kit/dist/modules/slug/buildSlugField.d.ts
T
2026-07-31 23:21:51 +02:00

31 lines
1.3 KiB
TypeScript

import type { Field, TextField } from 'payload';
/**
* Normalizes a string into a URL slug. slugify handles diacritics out of the
* box (Polish included: "Strona główna" → "strona-glowna").
*/
export declare function toSlug(input: string): string;
type BuildSlugFieldOptions = {
/** Source field to derive the slug from. Default: 'title'. */
from?: string;
/** Whether the slug is localized (per-locale). Default: true. */
localized?: boolean;
/** Field name for the slug. Default: 'slug'. */
name?: string;
/** Override or extend the generated field config. */
overrides?: Partial<TextField>;
/** Whether the slug is required. Default: true. */
required?: boolean;
};
/**
* Builds a slug field that auto-generates from a source field (default 'title')
* only when left empty — an editor's manual slug is never overwritten (mode 4a).
*
* Localized-safe: on a localized field Payload runs the hook per locale, so
* `value` is the slug for the active locale and `siblingData[from]` is the
* source in that same locale. Editing the doc in 'pl' fills slug.pl from
* title.pl; editing in 'en' fills slug.en from title.en — giving genuinely
* per-locale slugs (strona-glowna / homepage) that the language switcher needs.
*/
export declare function buildSlugField(options?: BuildSlugFieldOptions): Field;
export {};