Skip to content

Commit 5e175e5

Browse files
committed
fix anchor parsing
1 parent a88bcc0 commit 5e175e5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/components/links.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import {readdir, readFile, stat} from "fs/promises";
22

33
// Anchors can be derived from headers, or explicitly written as {#names}.
44
export function getAnchors(text) {
5+
text = text.replace(/<(?:Version)?Badge[^/]*\/>/g, ""); // ignore badges
56
const anchors = [];
67
for (const [, header] of text.matchAll(/^#+ ([*\w][*().,\w\d -]+)\n/gm)) {
78
anchors.push(
89
header
9-
.replaceAll(/[^\w\d\s]+/g, " ")
10+
.replace(/[^\w\d\s]+/g, " ")
1011
.trim()
11-
.replaceAll(/ +/g, "-")
12+
.replace(/ +/g, "-")
1213
.toLowerCase()
1314
);
1415
}

0 commit comments

Comments
 (0)