From e0eb38c4fb5e13a365305de27d452ebee0001f4a Mon Sep 17 00:00:00 2001 From: Emile Bangma Date: Wed, 2 Apr 2025 20:58:21 +0000 Subject: [PATCH] id mapping --- quartz/components/scripts/popover.inline.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/quartz/components/scripts/popover.inline.ts b/quartz/components/scripts/popover.inline.ts index e4d878f1d..6468e79f6 100644 --- a/quartz/components/scripts/popover.inline.ts +++ b/quartz/components/scripts/popover.inline.ts @@ -82,17 +82,15 @@ async function mouseEnterHandler( const contents = await response.text() const html = p.parseFromString(contents, "text/html") normalizeRelativeURLs(html, targetUrl) - // strip all IDs from elements to prevent duplicates on same-page links - if (thisUrl.pathname === targetUrl.pathname) { - html.querySelectorAll("[id]").forEach((el) => { - const targetID = `popover-${el.id}` - const targetLink = hash.startsWith("#popover") - ? hash - : `#popover-${hash.slice(1).replace("^", "").replace("%5E", "")}` - el.id = targetID - hash = targetLink - }) - } + // prepend all IDs inside popovers to prevent duplicates + html.querySelectorAll("[id]").forEach((el) => { + const targetID = `popover-${el.id}` + const targetLink = hash.startsWith("#popover") + ? hash + : `#popover-${hash.slice(1).replace("^", "").replace("%5E", "")}` + el.id = targetID + hash = targetLink + }) const elts = [...html.getElementsByClassName("popover-hint")] if (elts.length === 0) return