Leadtype
Reference

Frontmatter transformers

Custom frontmatter is first-class in Leadtype. Define a schema when your docs need product-specific fields, then use transformers to derive or normalize those fields as the pipeline runs.

Transformer hook types live under leadtype/transformers when you want explicit annotations in shared config helpers.

Use transformers for release-channel behavior such as canary, RC, preview, or stable builds. Those channels describe the build or deployment, not the page source, so they should be derived from config, environment, package version, or git ref instead of authored into page status.

docs.config.ts

Typed source data

Pass the same schema and transformers to lower-level APIs when you are not using leadtype generate:

Without a schema, frontmatter remains Record<string, unknown>. With a schema, page and transformer payloads are typed from the schema output.

Hook order

Transformers run in array order. A hook may return a replacement object or return nothing to keep the current value.

HookPurpose
beforeParseEdit raw source before frontmatter and MDX parsing.
afterFrontmatterAdd, validate, or normalize frontmatter-derived metadata.
afterMdxAstAdjust the transformed mdast before markdown serialization.
afterFlattenMarkdownCustomize flattened markdown before it is written or indexed.
beforeSearchIndexEdit the full search document list.
beforeSearchChunkEdit individual search chunks.
beforeLlmsTxtCustomize root or docs-scoped llms.txt.
beforeLlmsFullCustomize llms-full.txt.
beforeAgentsMdCustomize package-bundled AGENTS.md.

Hook errors include the transformer name, hook name, and source path when Leadtype has one.

beforeSearchChunk receives the current chunk text and metadata. If you change text, Leadtype recalculates the chunk length before indexing, so you do not need to update length manually.