Skip to content

Commit 11ffc16

Browse files
committed
chore: patch-vitepress
1 parent 7f2badd commit 11ffc16

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"dev": "vitepress dev .",
88
"build": "vitepress build .",
99
"format": "prettier --write \"**/*.{js,css,md}\"",
10-
"postinstall": "husky install",
11-
"scrape.plugins": "zx ./scripts/plugin-scraper.mjs && prettier --write \"./plugins/*.md\""
10+
"postinstall": "husky install && npm run patch.vitepress",
11+
"scrape.plugins": "zx ./scripts/plugin-scraper.mjs && prettier --write \"./plugins/*.md\"",
12+
"patch.vitepress": "zx ./scripts/patch-vitepress-deadLinks.mjs"
1213
},
1314
"devDependencies": {
1415
"@prettier/plugin-xml": "^1.1.0",

scripts/patch-vitepress-deadLinks.mjs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import 'zx/globals'
2+
3+
const vitepressLoc = require.resolve('vitepress')
4+
const vitepressDistPath = path.dirname(vitepressLoc)
5+
const files = fs.readdirSync(vitepressDistPath)
6+
const serveFile = files.find((file) => file.startsWith('serve-'))
7+
const serveFilePath = path.resolve(vitepressDistPath, serveFile)
8+
const serveFileContents = fs.readFileSync(serveFilePath).toString();
9+
10+
fs.writeFileSync(
11+
serveFilePath,
12+
serveFileContents.replace(
13+
'throw new Error(`One or more pages contain dead links.`);',
14+
'console.warn(`One or more pages contain dead links.`);'
15+
)
16+
)

0 commit comments

Comments
 (0)