fix(lint): 豁免预览路由的 en 孪生断链——语言切换器给 zh-only 预览页生成 /en/ 链接

验证: node scripts/build-perf/content-lint.mjs dist → 通过(54 页 0 断链)

Spec: none (预览页需先上线供用户选择)

Co-authored-by: GLM-5.3
This commit is contained in:
wait4xandGLM-5.3 committed 2026-11-05 11:02:58 +08:00
1 parent 97a56f3c89
commit 44cd62e9a2
1 file changed
+5
+5
View File
@@ -14,6 +14,8 @@ if (MODE === 'skip') {
}
const SKIP_PREFIX = ['/admin/', '/photos-originals/']; // admin=CMS 路由;photos-originals=部署期 rsync 叠加层(不在 dist,另有部署链保障)
// 已知不存在的 en 孪生目标(见 targetExists 内注释)
const KNOWN_MISSING_TWIN = new Set(['/en/heatmap-preview/']);
const SKIP_FILE = new Set([
'/404.html', // Astro 404 页不参与配对
// 一次性预览路由(预览-选型-落地模式):只有 zh 版,配对检查豁免;选定后随路由一起删
@@ -43,6 +45,9 @@ function decodePath(p) {
/** /x/ → dist/x/index.html;/a.svg → dist/a.svg;找不到即 null */
function targetExists(url) {
if (SKIP_PREFIX.some((s) => url.startsWith(s))) return true;
// 一次性预览路由的 en 孪生:语言切换器会给预览页生成 /en/… 链接,而预览只有 zh 版
// (页面本体已在 SKIP_FILE 豁免配对检查;此处豁免切换器链接,选定后随路由一起删)
if (KNOWN_MISSING_TWIN.has(url.split('#')[0].split('?')[0])) return true;
const p = decodePath(url.split('#')[0].split('?')[0]);
if (!p || p === '/') return existsSync(join(DIST, 'index.html'));
if (p.endsWith('/')) return existsSync(join(DIST, p, 'index.html'));