mirror of
https://github.com/quartz-community/types.git
synced 2026-07-22 02:50:26 +00:00
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:
parent
a945040888
commit
c7df97d0de
1 changed files with 5 additions and 0 deletions
|
|
@ -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[];
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
|||
Loading…
Reference in a new issue