fix(export/share): missing templates after merge

This commit is contained in:
Elian Doran 2025-10-24 14:54:20 +03:00
parent ea53665e64
commit aa102ab393
No known key found for this signature in database
2 changed files with 17 additions and 5 deletions

View File

@ -1,8 +1,9 @@
import type NoteMeta from "../../meta/note_meta.js"; import type NoteMeta from "../../meta/note_meta.js";
import { escapeHtml } from "../../utils"; import { escapeHtml, getResourceDir, isDev } from "../../utils";
import cssContent from "@triliumnext/ckeditor5/content.css";
import html from "html"; import html from "html";
import { ZipExportProvider } from "./abstract_provider.js"; import { ZipExportProvider } from "./abstract_provider.js";
import path from "path";
import fs from "fs";
export default class HtmlExportProvider extends ZipExportProvider { export default class HtmlExportProvider extends ZipExportProvider {
@ -164,6 +165,10 @@ export default class HtmlExportProvider extends ZipExportProvider {
return; return;
} }
const cssFile = isDev
? path.join(__dirname, "../../../../../node_modules/ckeditor5/dist/ckeditor5-content.css")
: path.join(getResourceDir(), "ckeditor5-content.css");
const cssContent = fs.readFileSync(cssFile, "utf-8");
this.archive.append(cssContent, { name: cssMeta.dataFileName }); this.archive.append(cssContent, { name: cssMeta.dataFileName });
} }

View File

@ -189,15 +189,22 @@ function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs)
} }
// Render with the default view otherwise. // Render with the default view otherwise.
const templatePath = join(getResourceDir(), "share-theme", "templates", "page.ejs"); const templatePath = getDefaultTemplatePath("page");
return ejs.render(readTemplate(templatePath), opts, { return ejs.render(readTemplate(templatePath), opts, {
includer: (path) => { includer: (path) => {
const templatePath = join(getResourceDir(), "share-theme", "templates", `${path}.ejs`); // Path is relative to apps/server/dist/assets/views
return { template: readTemplate(templatePath) }; return { template: readTemplate(getDefaultTemplatePath(path)) };
} }
}); });
} }
function getDefaultTemplatePath(template: string) {
// Path is relative to apps/server/dist/assets/views
return process.env.NODE_ENV === "development"
? join(__dirname, `../../../../packages/share-theme/src/templates/${template}.ejs`)
: `../../share-theme/templates/${template}.ejs`;
}
function readTemplate(path: string) { function readTemplate(path: string) {
const cachedTemplate = templateCache.get(path); const cachedTemplate = templateCache.get(path);
if (cachedTemplate) { if (cachedTemplate) {