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",