Skip to content

Commit 6fd4960

Browse files
committed
feat: improve example block anchor
1 parent 88384f7 commit 6fd4960

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/.vitepress/theme/anchor/exampleAutoAnchorPreprocessor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ export const exampleAutoAnchorPreprocessor = (md: MarkdownIt) => {
77
const processedLines = lines.map((line) => {
88
if (line.startsWith(":::") && (line.includes(":::tip Example") || line.includes("::: tip Example"))) {
99
const title = line.split(/tip (.+)/)[1]
10+
const processedTitle = slugify(title.replace(" – ", ""));
1011
return `
11-
<div style="height: 0; color: rgba(0,0,0,0%);position: relative;top: 50px">
12-
<h3 id="${slugify(title.replace(" – ", ""))}">${title}</h3>
12+
<div style="height: 0; color: rgba(0,0,0,0%);position: relative;top: 32px">
13+
<h3 id="${processedTitle}">${title}
14+
<a class="header-anchor" href="#${processedTitle}" aria-label="Permalink to &quot;${title}&quot;">​</a>
15+
</h3>
1316
</div>
1417
1518
${line}

0 commit comments

Comments
 (0)