Skip to content

Build your personal knowledge base with Trilium Notes

render js notes as-is

Wael Nasreddine94d1181fe861
diff --git a/apps/server/src/services/export/zip/share_theme.ts b/apps/server/src/services/export/zip/share_theme.ts
index 592eb94ec6..44571dbd7d 100644
--- a/apps/server/src/services/export/zip/share_theme.ts
+++ b/apps/server/src/services/export/zip/share_theme.ts
@@ -70,6 +70,7 @@ export default class ShareThemeExportProvider extends ZipExportProvider {
}) : "";
content = renderNoteForExport(note, branch, basePath, noteMeta.notePath.slice(0, -1));
+ // TODO: This will probably never match, but should it be exclude from running on code/jsFrontend notes?
if (typeof content === "string") {
content = content.replace(/href="[^"]*\.\/([a-zA-Z0-9_\/]{12})[^"]*"/g, (match, id) => {
if (match.includes("/assets/")) return match;
diff --git a/apps/server/src/share/content_renderer.ts b/apps/server/src/share/content_renderer.ts
index 70d7f2b820..897f103941 100644
--- a/apps/server/src/share/content_renderer.ts
+++ b/apps/server/src/share/content_renderer.ts
@@ -149,6 +149,15 @@ interface RenderArgs {
}
function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) {
+ if (renderArgs.isStatic && note.type == "code" && note.mime === "application/javascript;env=frontend") {
+ if (note.isProtected) {
+ // TODO: how to handle this case here?
+ throw new Error(`note ${note.noteId} is protected and cannot be exported`);
+ }
+
+ return note.getContent();
+ }
+
const { header, content, isEmpty } = getContent(note);
const showLoginInShareTheme = options.getOption("showLoginInShareTheme");
const opts = {