From fc5a1f49875db671b45df96b962ddfd3214b03c2 Mon Sep 17 00:00:00 2001 From: Andrew Kwon Date: Wed, 18 Feb 2026 19:53:35 -0800 Subject: [PATCH] fix: same-page transclusions with diff sections When a page embeds two different sections from the same note (e.g., `![[Note#Section A]]` and `![[Note#Section B]]`), the second transclusion is incorrectly flagged as circular. This happens because the `visited` set in `renderTranscludes` tracks targets by slug alone, so the second embed of the same file is treated as a cycle even though it references a different section. Include the block/section reference (`dataBlock`) in the visited key so that different sections of the same page are treated as distinct transclusion targets. Full-page transclusions (no section reference) still use the slug alone, preserving circular reference detection for actual cycles. --- quartz/components/renderPage.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/quartz/components/renderPage.tsx b/quartz/components/renderPage.tsx index 8cf54392c..e428f509d 100644 --- a/quartz/components/renderPage.tsx +++ b/quartz/components/renderPage.tsx @@ -78,7 +78,11 @@ function renderTranscludes( if (classNames.includes("transclude")) { const inner = node.children[0] as Element const transcludeTarget = (inner.properties["data-slug"] ?? slug) as FullSlug - if (visited.has(transcludeTarget)) { + const dataBlock = node.properties.dataBlock as string | undefined + const visitedKey = dataBlock + ? (`${transcludeTarget}${dataBlock}` as FullSlug) + : transcludeTarget + if (visited.has(visitedKey)) { console.warn( styleText( "yellow", @@ -100,7 +104,7 @@ function renderTranscludes( ] return } - visited.add(transcludeTarget) + visited.add(visitedKey) const page = componentData.allFiles.find((f) => f.slug === transcludeTarget) if (!page) {