调整代码结构以支持多种风格

This commit is contained in:
lutinglt
2025-02-21 21:47:54 +08:00
parent ba895a3f31
commit 8def32e5b9
33 changed files with 50 additions and 26 deletions

View File

@@ -5,6 +5,7 @@ import * as yaml from "npm:js-yaml";
interface Gitea {
version: string;
themes: [string];
}
interface ThemeInfo {
@@ -13,16 +14,17 @@ interface ThemeInfo {
async function generateTheme(themePath: string) {
try {
const inputFile = "src/theme-github.scss";
const outputFile = "dist/theme-github.css";
const result = await sass.compileAsync(inputFile, { sourceMap: false, style: "compressed" });
await Deno.mkdir("dist", { recursive: true });
await Deno.writeTextFile(outputFile, result.css);
const fileContent = await Deno.readTextFile(themePath);
const data: ThemeInfo = yaml.load(fileContent);
console.log(data.gitea.version);
await Deno.mkdir("dist", { recursive: true });
for (const theme of data.gitea.themes) {
const inputFile = `src/themes/theme-github-${theme}.scss`;
const outputFile = `dist/theme-github-${theme}.css`;
const result = await sass.compileAsync(inputFile, { sourceMap: false, style: "compressed" });
await Deno.writeTextFile(outputFile, result.css);
}
} catch (error) {
let e = error;
if (error instanceof Error) {