mirror of
https://github.com/zadam/trilium.git
synced 2025-12-28 18:24:27 +01:00
chore(icon_packs): process boxicons v2
This commit is contained in:
parent
59b691d670
commit
241a9e2e7f
8826
boxicons-v2.json
Normal file
8826
boxicons-v2.json
Normal file
File diff suppressed because it is too large
Load Diff
37
scripts/icon-packs/boxicons-v2.ts
Normal file
37
scripts/icon-packs/boxicons-v2.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { readFileSync, writeFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
import iconList from "../../apps/client/src/widgets/icon_list";
|
||||
|
||||
function readMappingsFromCss() {
|
||||
const cssPath = join(__dirname, "../../node_modules/boxicons/css/boxicons.css");
|
||||
const cssContent = readFileSync(cssPath, "utf-8");
|
||||
const mappings: Record<string, string> = {};
|
||||
const regex = /\.(bx.*?):before.*?\n.*?content:.*?"(.*?)"/g;
|
||||
let match;
|
||||
while ((match = regex.exec(cssContent)) !== null) {
|
||||
mappings[match[1]] = String.fromCharCode(parseInt(match[2].substring(1), 16));
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
const mappings = readMappingsFromCss();
|
||||
|
||||
const icons = {};
|
||||
for (const icon of iconList.icons) {
|
||||
if (!icon.className) continue;
|
||||
const className = icon.className.substring(3); // remove 'bx-' prefix
|
||||
if (className === "bx-empty") continue;
|
||||
|
||||
icons[className] = {
|
||||
glyph: mappings[className],
|
||||
terms: [ icon.name, ...(icon.term || []) ]
|
||||
};
|
||||
}
|
||||
|
||||
const manifest = {
|
||||
prefix: "bx",
|
||||
icons
|
||||
};
|
||||
|
||||
writeFileSync(join(__dirname, "../../apps/server/src/services/icon_pack_boxicons-v2.json"), JSON.stringify(manifest, null, 2));
|
||||
Loading…
x
Reference in New Issue
Block a user