Skip to content

Build your personal knowledge base with Trilium Notes

refactor(share): use internal rendering method for subtemplates

Elian Doranbc4643fed2ed
diff --git a/apps/server/src/share/content_renderer.ts b/apps/server/src/share/content_renderer.ts
index 62c9df71f2..529db21168 100644
--- a/apps/server/src/share/content_renderer.ts
+++ b/apps/server/src/share/content_renderer.ts
@@ -185,14 +185,18 @@ function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs)
// Render with the default view otherwise.
const templatePath = join(getResourceDir(), "share-theme", "templates", "page.ejs");
- return ejs.render(readFileSync(templatePath, "utf-8"), opts, {
+ return ejs.render(readTemplate(templatePath), opts, {
includer: (path) => {
const templatePath = join(getResourceDir(), "share-theme", "templates", `${path}.ejs`);
- return { filename: templatePath }
+ return { template: readTemplate(templatePath) };
}
});
}
+function readTemplate(path: string) {
+ return readFileSync(path, "utf-8");
+}
+
function getContent(note: SNote | BNote) {
if (note.isProtected) {
return {