aboutsummaryrefslogtreecommitdiff
path: root/doc/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'doc/scripts')
-rw-r--r--doc/scripts/fix-css-link-rel.mjs32
1 files changed, 0 insertions, 32 deletions
diff --git a/doc/scripts/fix-css-link-rel.mjs b/doc/scripts/fix-css-link-rel.mjs
deleted file mode 100644
index 4c48868..0000000
--- a/doc/scripts/fix-css-link-rel.mjs
+++ /dev/null
@@ -1,32 +0,0 @@
1import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
2import { join } from "node:path";
3
4const distRoot = "docs/.vitepress/dist";
5const preloadStylesheetRelPattern = /rel="preload stylesheet"/g;
6const stylesheetAsPattern = /(<link[^>]*rel="stylesheet"[^>]*?)\s+as="style"/g;
7
8function walk(dir, files = []) {
9 for (const entry of readdirSync(dir)) {
10 const fullPath = join(dir, entry);
11 const stat = statSync(fullPath);
12 if (stat.isDirectory()) {
13 walk(fullPath, files);
14 } else if (fullPath.endsWith(".html")) {
15 files.push(fullPath);
16 }
17 }
18 return files;
19}
20
21let updated = 0;
22for (const filePath of walk(distRoot)) {
23 const original = readFileSync(filePath, "utf8");
24 let fixed = original.replace(preloadStylesheetRelPattern, 'rel="stylesheet"');
25 fixed = fixed.replace(stylesheetAsPattern, "$1");
26 if (fixed !== original) {
27 writeFileSync(filePath, fixed, "utf8");
28 updated += 1;
29 }
30}
31
32console.log(`[fix-css-link-rel] Updated ${updated} HTML files.`);