Fixes #803
parent
ca5b6803eb
commit
a0f7230776
|
@ -12,9 +12,16 @@ type AnchorObject = ObjectValue<{
|
||||||
|
|
||||||
export async function indexAnchors({ name: pageName, tree }: IndexTreeEvent) {
|
export async function indexAnchors({ name: pageName, tree }: IndexTreeEvent) {
|
||||||
const anchors: ObjectValue<AnchorObject>[] = [];
|
const anchors: ObjectValue<AnchorObject>[] = [];
|
||||||
|
const anchorNames = new Set<string>();
|
||||||
|
|
||||||
collectNodesOfType(tree, "NamedAnchor").forEach((n) => {
|
collectNodesOfType(tree, "NamedAnchor").forEach((n) => {
|
||||||
const aName = n.children![0].text!.substring(1);
|
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({
|
anchors.push({
|
||||||
ref: `${pageName}$${aName}`,
|
ref: `${pageName}$${aName}`,
|
||||||
tag: "anchor",
|
tag: "anchor",
|
||||||
|
|
Loading…
Reference in New Issue