From a0f72307760d15c8b80b65caf8f375d579ed3248 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 14 Mar 2024 20:39:38 +0100 Subject: [PATCH] Fixes #803 --- plugs/index/anchor.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugs/index/anchor.ts b/plugs/index/anchor.ts index 39d85d40..2a596162 100644 --- a/plugs/index/anchor.ts +++ b/plugs/index/anchor.ts @@ -12,9 +12,16 @@ type AnchorObject = ObjectValue<{ export async function indexAnchors({ name: pageName, tree }: IndexTreeEvent) { const anchors: ObjectValue[] = []; + const anchorNames = new Set(); collectNodesOfType(tree, "NamedAnchor").forEach((n) => { const aName = n.children![0].text!.substring(1); + if (anchorNames.has(aName)) { + console.warn("Duplicate anchor", aName, "in", pageName); + return; + } else { + anchorNames.add(aName); + } anchors.push({ ref: `${pageName}$${aName}`, tag: "anchor",