This commit is contained in:
2026-01-18 14:48:40 +08:00
parent 34f5211d15
commit cc3945ccc6

View File

@@ -27,7 +27,8 @@ const primaryRgb = hexToRgb(primaryColor);
// proper head script entries to avoid inserting raw HTML into a script // proper head script entries to avoid inserting raw HTML into a script
// element (which causes JS parse errors like "Unexpected token '<'"). // element (which causes JS parse errors like "Unexpected token '<'").
const traceRaw = siteConfig.traceConfig?.script || ""; const traceRaw = siteConfig.traceConfig?.script || "";
const traceScripts = [] as any[]; type TraceScript = { src?: string; children?: string; type?: string };
const traceScripts: TraceScript[] = [];
if (typeof traceRaw === "string" && traceRaw.trim()) { if (typeof traceRaw === "string" && traceRaw.trim()) {
// find all <script ... src="..."> tags and extract src // find all <script ... src="..."> tags and extract src
const srcRegex = /<script[^>]*src=["']([^"']+)["'][^>]*>\s*<\/script>/gi; const srcRegex = /<script[^>]*src=["']([^"']+)["'][^>]*>\s*<\/script>/gi;