Files
gitea-themes/styles/tokens/required.ts
T
chuan 8dd9e1a71a
Release / release (push) Successful in 37s
fix: 修复缺失语法高亮的问题
2026-05-21 23:35:28 +08:00

30 lines
841 B
TypeScript

const requiredRootTokens = [
"--theme-version",
"--is-dark-theme",
"--color-primary",
"--color-body",
"--color-text",
"--color-input-background",
"--color-light-border",
"--border-radius",
"--github-bgColor-accent-emphasis",
"--color-syntax-keyword",
"--color-syntax-string",
"--color-syntax-comment",
"--color-syntax-number",
"--color-syntax-invalid",
"--color-nav-hoverBg",
"--color-label-hoverBg",
"--color-reaction-hoverBg",
"--color-workflowEdgeHover",
];
export function validateRequiredTokens(rootTokens: string): void {
const available = new Set(rootTokens.match(/--[A-Za-z0-9_-]+(?=\s*:)/g) ?? []);
const missing = requiredRootTokens.filter((token) => !available.has(token));
if (missing.length > 0) {
throw new Error(`theme is missing required tokens: ${missing.join(", ")}`);
}
}