From d8958adea5c13ced699db18fff9dace3db7689dd Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 14 Jun 2025 00:07:55 +0300 Subject: [PATCH] feat(export/zip): basic tree navigation --- apps/server/src/services/export/zip.ts | 3 +++ packages/share-theme/src/templates/tree_item.ejs | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/server/src/services/export/zip.ts b/apps/server/src/services/export/zip.ts index 8d8d2de07..bb3e382be 100644 --- a/apps/server/src/services/export/zip.ts +++ b/apps/server/src/services/export/zip.ts @@ -333,6 +333,9 @@ async function exportToZip(taskContext: TaskContext, branch: BBranch, format: "h if (note) { content = renderNoteForExport(note, branch, basePath); + + // TODO: Fix double rewrite. + content = rewriteFn(content, noteMeta); } else { const cssUrl = basePath + "style.css"; // element will make sure external links are openable - https://github.com/zadam/trilium/issues/1289#issuecomment-704066809 diff --git a/packages/share-theme/src/templates/tree_item.ejs b/packages/share-theme/src/templates/tree_item.ejs index b033ad2bc..99da978fa 100644 --- a/packages/share-theme/src/templates/tree_item.ejs +++ b/packages/share-theme/src/templates/tree_item.ejs @@ -1,7 +1,16 @@ <% const linkClass = `type-${note.type}` + (activeNote.noteId === note.noteId ? " active" : ""); const isExternalLink = note.hasLabel("shareExternal"); -const linkHref = isExternalLink ? note.getLabelValue("shareExternal") : `./${note.shareId}`; +let linkHref; + +if (isExternalLink) { + linkHref = note.getLabelValue("shareExternal"); +} else if (note.shareId) { + linkHref = `./${note.shareId}`; +} else { + linkHref = `#${note.getBestNotePath().join("/")}`; +} + const target = isExternalLink ? ` target="_blank" rel="noopener noreferrer"` : ""; %>