From 0593c8cd6a71e9b1d09320075f820d81de3d5407 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Sat, 23 May 2026 01:18:30 +0200 Subject: [PATCH] fix: allow arbitrary transclusion --- quartz/plugins/pageTypes/dispatcher.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/quartz/plugins/pageTypes/dispatcher.ts b/quartz/plugins/pageTypes/dispatcher.ts index 803a076..bb6b6de 100644 --- a/quartz/plugins/pageTypes/dispatcher.ts +++ b/quartz/plugins/pageTypes/dispatcher.ts @@ -198,12 +198,16 @@ export const PageTypeDispatcher: QuartzEmitterPlugin> } } - // Render Body components to populate htmlAst for transclusion - populateVirtualPageHtmlAst(virtualEntries, ctx, allFiles, resources) - - // Merge virtual page data into allFiles so renderPage can resolve transcludes + // Merge virtual page data into allFiles before populating htmlAst so that + // Body components rendered during populateVirtualPageHtmlAst can resolve + // cross-virtual-page embeds (e.g. a .base file embedded in a .canvas file). + // The vfile.data objects are shared by reference, so htmlAst set on earlier + // entries becomes visible to later entries in the same pass. const allFilesWithVirtual = [...allFiles, ...virtualEntries.map((ve) => ve.vfile.data)] + // Render Body components to populate htmlAst for transclusion + populateVirtualPageHtmlAst(virtualEntries, ctx, allFilesWithVirtual, resources) + // Phase 2: Emit regular pages (with virtual page data available for transclusion) for (const [tree, file] of content) { const slug = file.data.slug! @@ -288,12 +292,11 @@ export const PageTypeDispatcher: QuartzEmitterPlugin> } } - // Render Body components to populate htmlAst for transclusion - populateVirtualPageHtmlAst(virtualEntries, ctx, allFiles, resources) - - // Merge virtual page data into allFiles for transclude resolution const allFilesWithVirtual = [...allFiles, ...virtualEntries.map((ve) => ve.vfile.data)] + // Render Body components to populate htmlAst for transclusion + populateVirtualPageHtmlAst(virtualEntries, ctx, allFilesWithVirtual, resources) + // Phase 2: Emit changed regular pages for (const [tree, file] of content) { const slug = file.data.slug!