mirror of
https://github.com/zadam/trilium.git
synced 2026-01-05 06:04:25 +01:00
feat(icon_packs): use note title isntead of manifest
This commit is contained in:
parent
8053221b12
commit
13fff33aa4
@ -2,7 +2,6 @@ import { buildNote } from "../test/becca_easy_mocking";
|
||||
import { determineBestFontAttachment, generateCss, generateIconRegistry, IconPackManifest, processIconPack } from "./icon_packs";
|
||||
|
||||
const manifest: IconPackManifest = {
|
||||
name: "Boxicons v2",
|
||||
prefix: "bx",
|
||||
icons: {
|
||||
"bx-ball": {
|
||||
@ -33,6 +32,7 @@ describe("Processing icon packs", () => {
|
||||
|
||||
it("processes manifest", () => {
|
||||
const iconPack = processIconPack(buildNote({
|
||||
title: "Boxicons v2",
|
||||
type: "text",
|
||||
content: JSON.stringify(manifest),
|
||||
attachments: [ defaultAttachment ]
|
||||
@ -111,7 +111,6 @@ describe("Mapping attachments", () => {
|
||||
describe("CSS generation", () => {
|
||||
it("generates the CSS", () => {
|
||||
const manifest: IconPackManifest = {
|
||||
name: "Boxicons v2",
|
||||
prefix: "bx",
|
||||
icons: {
|
||||
"bx-ball": {
|
||||
@ -126,6 +125,7 @@ describe("CSS generation", () => {
|
||||
};
|
||||
const processedResult = processIconPack(buildNote({
|
||||
type: "text",
|
||||
title: "Boxicons v2",
|
||||
content: JSON.stringify(manifest),
|
||||
attachments: [
|
||||
{
|
||||
@ -153,6 +153,7 @@ describe("CSS generation", () => {
|
||||
describe("Icon registery", () => {
|
||||
it("generates the registry", () => {
|
||||
const iconPack = processIconPack(buildNote({
|
||||
title: "Boxicons v2",
|
||||
type: "text",
|
||||
content: JSON.stringify(manifest),
|
||||
attachments: [ defaultAttachment ]
|
||||
|
||||
@ -19,7 +19,6 @@ const MIME_TO_CSS_FORMAT_MAPPINGS: Record<typeof PREFERRED_MIME_TYPE[number], st
|
||||
};
|
||||
|
||||
export interface IconPackManifest {
|
||||
name: string;
|
||||
prefix: string;
|
||||
icons: Record<string, {
|
||||
glyph: string,
|
||||
@ -31,6 +30,7 @@ interface ProcessResult {
|
||||
manifest: IconPackManifest;
|
||||
fontMime: string;
|
||||
fontAttachmentId: string;
|
||||
manifestNote: BNote;
|
||||
}
|
||||
|
||||
export function getIconPacks() {
|
||||
@ -42,7 +42,7 @@ export function getIconPacks() {
|
||||
export function generateIconRegistry(iconPacks: ProcessResult[]): IconRegistry {
|
||||
const sources: IconRegistry["sources"] = [];
|
||||
|
||||
for (const { manifest } of iconPacks) {
|
||||
for (const { manifest, manifestNote } of iconPacks) {
|
||||
const icons: IconRegistry["sources"][number]["icons"] = Object.entries(manifest.icons)
|
||||
.map(( [id, { terms }] ) => {
|
||||
if (!id || !terms) return null;
|
||||
@ -53,7 +53,7 @@ export function generateIconRegistry(iconPacks: ProcessResult[]): IconRegistry {
|
||||
|
||||
sources.push({
|
||||
prefix: manifest.prefix,
|
||||
name: manifest.name,
|
||||
name: manifestNote.title,
|
||||
icons
|
||||
});
|
||||
}
|
||||
@ -77,7 +77,8 @@ export function processIconPack(iconPackNote: BNote): ProcessResult | undefined
|
||||
return {
|
||||
manifest,
|
||||
fontMime: attachment.mime,
|
||||
fontAttachmentId: attachment.attachmentId
|
||||
fontAttachmentId: attachment.attachmentId,
|
||||
manifestNote: iconPackNote
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user