mirror of
https://github.com/zadam/trilium.git
synced 2026-01-10 16:44:29 +01:00
feat(share): Render JS Frontend files as-is with extension .js (#8172)
This commit is contained in:
commit
59bbd902fc
@ -74,6 +74,7 @@ export default class ShareThemeExportProvider extends ZipExportProvider {
|
|||||||
whitespaceCharacters: "\t\r\n\f\u200b\u00a0\u2002"
|
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);
|
content = renderNoteForExport(note, branch, basePath, noteMeta.notePath.slice(0, -1), this.iconPacks);
|
||||||
if (typeof content === "string") {
|
if (typeof content === "string") {
|
||||||
// Rewrite attachment download links
|
// Rewrite attachment download links
|
||||||
@ -130,6 +131,10 @@ export default class ShareThemeExportProvider extends ZipExportProvider {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mime.startsWith("application/javascript")) {
|
||||||
|
return "js";
|
||||||
|
}
|
||||||
|
|
||||||
// Don't add .html if the file already has .zip extension (for attachments).
|
// Don't add .html if the file already has .zip extension (for attachments).
|
||||||
if (existingExtension === ".zip") {
|
if (existingExtension === ".zip") {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -165,6 +165,15 @@ interface RenderArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderNoteContentInternal(note: SNote | BNote, renderArgs: 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 { header, content, isEmpty } = getContent(note);
|
||||||
const showLoginInShareTheme = options.getOption("showLoginInShareTheme");
|
const showLoginInShareTheme = options.getOption("showLoginInShareTheme");
|
||||||
const opts = {
|
const opts = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user