Skip to content

Commit 2e146db

Browse files
committed
refactor: Update generateCliDocs to properly escape links, so that they are valid in vitepress
1 parent ad3f141 commit 2e146db

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

scripts/generateCliDoc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ import {fileURLToPath} from "node:url";
44
import Handlebars from "handlebars";
55

66
const source = readFileSync(fileURLToPath(new URL("../scripts/resources/CLI.template.md", import.meta.url)), "utf8");
7+
8+
// Register Handlebars helper to escape URLs for VitePress
9+
Handlebars.registerHelper("escapeUrls", function(text) {
10+
if (!text) return text;
11+
// Escape localhost URLs to prevent VitePress from treating them as dead links
12+
return text.replace(/http:\/\/localhost:\d+\/[^\s)]+/g, (match) => `\`${match}\``);
13+
});
14+
715
const template = Handlebars.compile(source);
816

917

scripts/resources/CLI.template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ These options you can use with each command.
3535
## Examples
3636

3737
{{#each commonExamples}}
38-
{{commonExampleDescription}}
38+
{{{escapeUrls commonExampleDescription}}}
3939
```
4040
{{commonExample}}
4141
```
@@ -90,7 +90,7 @@ These options you can use with each command.
9090
**Examples**
9191

9292
{{#each examples}}
93-
{{exampleDescription}}
93+
{{{escapeUrls exampleDescription}}}
9494
```
9595
{{example}}
9696
```

0 commit comments

Comments
 (0)