mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2025-10-26 13:00:31 +00:00
调整代码结构以支持多种风格
This commit is contained in:
@@ -12,6 +12,9 @@ end_of_line = lf
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.{css,scss,ts}]
|
||||||
|
max_line_length = 120
|
||||||
|
|
||||||
# documentation, utils
|
# documentation, utils
|
||||||
[*.{md,mdx,diff}]
|
[*.{md,mdx,diff}]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|||||||
29
build.js
Normal file
29
build.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import * as process from "node:process";
|
||||||
|
import * as fs from "node:fs";
|
||||||
|
import * as sass from "sass";
|
||||||
|
import * as yaml from "js-yaml";
|
||||||
|
|
||||||
|
async function generateTheme(themePath) {
|
||||||
|
try {
|
||||||
|
const fileContent = fs.readFileSync(themePath);
|
||||||
|
const data = yaml.load(fileContent);
|
||||||
|
console.log(data.gitea.version);
|
||||||
|
|
||||||
|
fs.mkdirSync("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" });
|
||||||
|
fs.writeFileSync(outputFile, result.css);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
let e = error;
|
||||||
|
if (error instanceof Error) {
|
||||||
|
e = error.message;
|
||||||
|
}
|
||||||
|
console.error("Build failed:", e);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generateTheme("theme.yml");
|
||||||
16
build.ts
16
build.ts
@@ -5,6 +5,7 @@ import * as yaml from "npm:js-yaml";
|
|||||||
|
|
||||||
interface Gitea {
|
interface Gitea {
|
||||||
version: string;
|
version: string;
|
||||||
|
themes: [string];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ThemeInfo {
|
interface ThemeInfo {
|
||||||
@@ -13,16 +14,17 @@ interface ThemeInfo {
|
|||||||
|
|
||||||
async function generateTheme(themePath: string) {
|
async function generateTheme(themePath: string) {
|
||||||
try {
|
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 fileContent = await Deno.readTextFile(themePath);
|
||||||
const data: ThemeInfo = yaml.load(fileContent);
|
const data: ThemeInfo = yaml.load(fileContent);
|
||||||
console.log(data.gitea.version);
|
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) {
|
} catch (error) {
|
||||||
let e = error;
|
let e = error;
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
|
|||||||
@@ -6,6 +6,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"build": "./build.ts"
|
"build": "deno -A --allow-scripts build.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
package.json
17
package.json
@@ -1,21 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "gitea-github-theme",
|
"type": "module",
|
||||||
"description": "尽量保持与 GitHub Dark 相同样式的 Gitea 主题",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"export": "sass src/theme-github.scss:dist/theme-github.css --no-source-map",
|
"build": "node build.js"
|
||||||
"build": "npm run export -- --style=compressed",
|
|
||||||
"watch": "npm run export -- --watch"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/lutinglt/gitea-github-theme.git"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/lutinglt/gitea-github-theme/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/lutinglt/gitea-github-theme#readme",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"sass": "^1.83.0"
|
"sass": "^1.83.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
/* Made by Luting ^-^ */
|
/* Made by Luting ^-^ */
|
||||||
@use "styles";
|
|
||||||
@use "public";
|
@use "public";
|
||||||
@use "components";
|
@use "components";
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Made by Luting ^-^
|
|
||||||
@use "styles/github.css"; // GitHub 变量(仅主题内部使用的变量)
|
|
||||||
@use "styles/gitea.css"; // Gitea 变量(元素默认使用的变量)
|
|
||||||
4
src/themes/theme-github-dark.scss
Normal file
4
src/themes/theme-github-dark.scss
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// Made by Luting ^-^
|
||||||
|
@use "../sass/theme-github";
|
||||||
|
@use "../styles/dark/github-dark.css"; // GitHub 变量(仅主题内部使用的变量)
|
||||||
|
@use "../styles/dark/gitea-dark.css"; // Gitea 变量(元素默认使用的变量)
|
||||||
Reference in New Issue
Block a user