feat(export/zip): get logo to work

This commit is contained in:
Elian Doran 2025-06-14 01:01:12 +03:00
parent 01a552ceb5
commit d3115e834a
No known key found for this signature in database
3 changed files with 13 additions and 5 deletions

View File

@ -24,6 +24,7 @@ import type { Response } from "express";
import type { NoteMetaFile } from "../meta/note_meta.js";
//import cssContent from "@triliumnext/ckeditor5/content.css";
import { renderNoteForExport } from "../../share/content_renderer.js";
import { RESOURCE_DIR } from "../resource_dir.js";
type RewriteLinksFn = (content: string, noteMeta: NoteMeta) => string;
@ -567,6 +568,7 @@ ${markdownContent}`;
"boxicons.woff",
"boxicons.ttf",
"boxicons.svg",
"icon-color.svg"
];
for (const asset of assets) {
@ -655,7 +657,9 @@ function getShareThemeAssets(nameWithExtension: string) {
}
let path: string | undefined;
if (isDev) {
if (nameWithExtension === "icon-color.svg") {
path = join(RESOURCE_DIR, "images", nameWithExtension);
} else if (isDev) {
path = join(getResourceDir(), "..", "..", "client", "dist", "src", nameWithExtension);
}

View File

@ -72,7 +72,8 @@ export function renderNoteForExport(note: BNote, parentBranch: BBranch, basePath
cssToLoad: [
`${basePath}style.css`,
`${basePath}boxicons.css`
]
],
logoUrl: `${basePath}icon-color.svg`
});
}
@ -91,10 +92,14 @@ export function renderNoteContent(note: SNote) {
cssToLoad.push(`api/notes/${cssRelation.value}/download`);
}
const customLogoId = note.getRelation("shareLogo")?.value;
const logoUrl = customLogoId ? `api/images/${customLogoId}/image.png` : `../${assetUrlFragment}/images/icon-color.svg`;
return renderNoteContentInternal(note, {
subRoot,
rootNoteId: "_share",
cssToLoad
cssToLoad,
logoUrl
});
}
@ -102,6 +107,7 @@ interface RenderArgs {
subRoot: Subroot;
rootNoteId: string;
cssToLoad: string[];
logoUrl: string;
}
function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) {

View File

@ -49,8 +49,6 @@
<meta name="theme-color" content="<%= openGraphColor %>">
</head>
<%
const customLogoId = subRoot.note.getRelation("shareLogo")?.value;
const logoUrl = customLogoId ? `api/images/${customLogoId}/image.png` : `../${assetUrlFragment}/images/icon-color.svg`;
const logoWidth = subRoot.note.getLabelValue("shareLogoWidth") ?? 53;
const logoHeight = subRoot.note.getLabelValue("shareLogoHeight") ?? 40;
const mobileLogoHeight = logoHeight && logoWidth ? 32 / (logoWidth / logoHeight) : "";