feat: add TreeTransform type and treeTransforms field to PageType plugin

Add TreeTransform type for render-time HAST tree mutations, enabling
pageType plugins to register tree walkers that run after transclusion
when allFiles data is available. Used by bases-page for inline
```base codeblock support.
This commit is contained in:
saberzero1 2026-03-07 22:12:08 +01:00
parent a945040888
commit c7df97d0de
No known key found for this signature in database

View file

@ -245,6 +245,9 @@ export type PageGenerator = (args: {
ctx: BuildCtx;
}) => VirtualPage[];
/** A function that mutates a HAST tree at render time, when allFiles is available. */
export type TreeTransform = (root: HtmlRoot, slug: FullSlug, componentData: QuartzComponentProps) => void;
/**
* A PageType plugin definition.
*
@ -273,6 +276,8 @@ export type QuartzPageTypePluginInstance = {
frame?: string;
/** The body component constructor for this page type. */
body: QuartzComponentConstructor;
/** Optional render-time HAST tree transforms (e.g. resolving inline codeblocks). */
treeTransforms?: (ctx: BuildCtx) => TreeTransform[];
};
// ============================================================================