22 lines
962 B
TypeScript
22 lines
962 B
TypeScript
import type { CollectionBeforeChangeHook } from 'payload';
|
|
/**
|
|
* Maps document fields to SEO meta fields for auto-fill.
|
|
* Defaults match the Payload website template (title → meta.title).
|
|
*/
|
|
export type AutoFillMapping = {
|
|
/** Document field used to fill meta.description when empty. */
|
|
description?: string;
|
|
/** Document field used to fill meta.title when empty. Default: 'title'. */
|
|
title?: string;
|
|
};
|
|
/**
|
|
* Builds a beforeChange hook that fills empty SEO meta fields from document
|
|
* content. Only fills when the meta field is blank — never overwrites what an
|
|
* editor typed. This runs server-side on every create/update, so editors get
|
|
* sensible meta without clicking "auto-generate".
|
|
*
|
|
* The plugin doesn't know the client's collection shape, so the field mapping
|
|
* is configurable; defaults follow the website template.
|
|
*/
|
|
export declare function buildAutoFillMetaHook(mapping?: AutoFillMapping): CollectionBeforeChangeHook;
|