From 5391e4112e513b8052bc700bc0f062aebdfb8098 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 12 Feb 2026 11:04:12 +0800 Subject: Try fix doc css issue. [skip CI] --- doc/scripts/fix-css-link-rel.mjs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 doc/scripts/fix-css-link-rel.mjs (limited to 'doc/scripts/fix-css-link-rel.mjs') diff --git a/doc/scripts/fix-css-link-rel.mjs b/doc/scripts/fix-css-link-rel.mjs new file mode 100644 index 0000000..9cbc9ea --- /dev/null +++ b/doc/scripts/fix-css-link-rel.mjs @@ -0,0 +1,30 @@ +import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; + +const distRoot = "docs/.vitepress/dist"; +const cssRelPattern = /rel="preload stylesheet"/g; + +function walk(dir, files = []) { + for (const entry of readdirSync(dir)) { + const fullPath = join(dir, entry); + const stat = statSync(fullPath); + if (stat.isDirectory()) { + walk(fullPath, files); + } else if (fullPath.endsWith(".html")) { + files.push(fullPath); + } + } + return files; +} + +let updated = 0; +for (const filePath of walk(distRoot)) { + const original = readFileSync(filePath, "utf8"); + const fixed = original.replace(cssRelPattern, 'rel="stylesheet"'); + if (fixed !== original) { + writeFileSync(filePath, fixed, "utf8"); + updated += 1; + } +} + +console.log(`[fix-css-link-rel] Updated ${updated} HTML files.`); -- cgit v1.2.3-55-g6feb