From c7df97d0def545b73fe433b7ef9d8ffb6694cf57 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Sat, 7 Mar 2026 22:12:08 +0100 Subject: [PATCH] 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. --- src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.ts b/src/index.ts index aa91f96..f669c52 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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[]; }; // ============================================================================