render js notes as-is

This commit is contained in:
Wael Nasreddine 2025-12-25 21:52:35 -08:00
parent 7e45aaa1da
commit 94d1181fe8
2 changed files with 10 additions and 0 deletions

View File

@ -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;

View File

@ -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 = {