mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	feat(export/zip): get logo to work
This commit is contained in:
		
							parent
							
								
									01a552ceb5
								
							
						
					
					
						commit
						d3115e834a
					
				@ -24,6 +24,7 @@ import type { Response } from "express";
 | 
				
			|||||||
import type { NoteMetaFile } from "../meta/note_meta.js";
 | 
					import type { NoteMetaFile } from "../meta/note_meta.js";
 | 
				
			||||||
//import cssContent from "@triliumnext/ckeditor5/content.css";
 | 
					//import cssContent from "@triliumnext/ckeditor5/content.css";
 | 
				
			||||||
import { renderNoteForExport } from "../../share/content_renderer.js";
 | 
					import { renderNoteForExport } from "../../share/content_renderer.js";
 | 
				
			||||||
 | 
					import { RESOURCE_DIR } from "../resource_dir.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RewriteLinksFn = (content: string, noteMeta: NoteMeta) => string;
 | 
					type RewriteLinksFn = (content: string, noteMeta: NoteMeta) => string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -567,6 +568,7 @@ ${markdownContent}`;
 | 
				
			|||||||
            "boxicons.woff",
 | 
					            "boxicons.woff",
 | 
				
			||||||
            "boxicons.ttf",
 | 
					            "boxicons.ttf",
 | 
				
			||||||
            "boxicons.svg",
 | 
					            "boxicons.svg",
 | 
				
			||||||
 | 
					            "icon-color.svg"
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (const asset of assets) {
 | 
					        for (const asset of assets) {
 | 
				
			||||||
@ -655,7 +657,9 @@ function getShareThemeAssets(nameWithExtension: string) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let path: string | undefined;
 | 
					    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);
 | 
					        path = join(getResourceDir(), "..", "..", "client", "dist", "src", nameWithExtension);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -72,7 +72,8 @@ export function renderNoteForExport(note: BNote, parentBranch: BBranch, basePath
 | 
				
			|||||||
        cssToLoad: [
 | 
					        cssToLoad: [
 | 
				
			||||||
            `${basePath}style.css`,
 | 
					            `${basePath}style.css`,
 | 
				
			||||||
            `${basePath}boxicons.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`);
 | 
					        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, {
 | 
					    return renderNoteContentInternal(note, {
 | 
				
			||||||
        subRoot,
 | 
					        subRoot,
 | 
				
			||||||
        rootNoteId: "_share",
 | 
					        rootNoteId: "_share",
 | 
				
			||||||
        cssToLoad
 | 
					        cssToLoad,
 | 
				
			||||||
 | 
					        logoUrl
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -102,6 +107,7 @@ interface RenderArgs {
 | 
				
			|||||||
    subRoot: Subroot;
 | 
					    subRoot: Subroot;
 | 
				
			||||||
    rootNoteId: string;
 | 
					    rootNoteId: string;
 | 
				
			||||||
    cssToLoad: string[];
 | 
					    cssToLoad: string[];
 | 
				
			||||||
 | 
					    logoUrl: string;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) {
 | 
					function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) {
 | 
				
			||||||
 | 
				
			|||||||
@ -49,8 +49,6 @@
 | 
				
			|||||||
    <meta name="theme-color" content="<%= openGraphColor %>">
 | 
					    <meta name="theme-color" content="<%= openGraphColor %>">
 | 
				
			||||||
</head>
 | 
					</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 logoWidth = subRoot.note.getLabelValue("shareLogoWidth") ?? 53;
 | 
				
			||||||
const logoHeight = subRoot.note.getLabelValue("shareLogoHeight") ?? 40;
 | 
					const logoHeight = subRoot.note.getLabelValue("shareLogoHeight") ?? 40;
 | 
				
			||||||
const mobileLogoHeight = logoHeight && logoWidth ? 32 / (logoWidth / logoHeight) : "";
 | 
					const mobileLogoHeight = logoHeight && logoWidth ? 32 / (logoWidth / logoHeight) : "";
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user