diff --git a/apps/server/src/services/export/zip/share_theme.ts b/apps/server/src/services/export/zip/share_theme.ts index ba1703163..316984d50 100644 --- a/apps/server/src/services/export/zip/share_theme.ts +++ b/apps/server/src/services/export/zip/share_theme.ts @@ -74,6 +74,7 @@ export default class ShareThemeExportProvider extends ZipExportProvider { whitespaceCharacters: "\t\r\n\f\u200b\u00a0\u2002" }) : ""; + // TODO: This will probably never match, but should it be exclude from running on code/jsFrontend notes? content = renderNoteForExport(note, branch, basePath, noteMeta.notePath.slice(0, -1), this.iconPacks); if (typeof content === "string") { // Rewrite attachment download links @@ -130,6 +131,10 @@ export default class ShareThemeExportProvider extends ZipExportProvider { return null; } + if (mime.startsWith("application/javascript")) { + return "js"; + } + // Don't add .html if the file already has .zip extension (for attachments). if (existingExtension === ".zip") { return null; diff --git a/apps/server/src/share/content_renderer.ts b/apps/server/src/share/content_renderer.ts index 6a6f47432..4f9646e82 100644 --- a/apps/server/src/share/content_renderer.ts +++ b/apps/server/src/share/content_renderer.ts @@ -165,6 +165,15 @@ interface RenderArgs { } function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) { + // When rendering static share, non-protected JavaScript notes should be rendered as-is. + if (renderArgs.isStatic && note.mime.startsWith("application/javascript")) { + if (note.isProtected) { + return `console.log("Protected note cannot be exported.");`; + } + + return note.getContent() ?? ""; + } + const { header, content, isEmpty } = getContent(note); const showLoginInShareTheme = options.getOption("showLoginInShareTheme"); const opts = {