Skip to content

Build your personal knowledge base with Trilium Notes

feat(share): render included notes

Elian Doran9921d3e0a755
diff --git a/apps/server/src/share/content_renderer.ts b/apps/server/src/share/content_renderer.ts
index c1c16e48d0..c12e7887f2 100644
--- a/apps/server/src/share/content_renderer.ts
+++ b/apps/server/src/share/content_renderer.ts
@@ -68,6 +68,21 @@ function renderIndex(result: Result) {
function renderText(result: Result, note: SNote) {
const document = new JSDOM(result.content || "").window.document;
+ // Process include notes.
+ for (const includeNoteEl of document.querySelectorAll("section.include-note")) {
+ const noteId = includeNoteEl.getAttribute("data-note-id");
+ if (!noteId) continue;
+
+ const note = shaca.getNote(noteId);
+ if (!note) continue;
+
+ const includedResult = getContent(note);
+ if (typeof includedResult.content !== "string") continue;
+
+ const includedDocument = new JSDOM(includedResult.content).window.document;
+ includeNoteEl.replaceWith(includedDocument.body);
+ }
+
result.isEmpty = document.body.textContent?.trim().length === 0 && document.querySelectorAll("img").length === 0;
if (!result.isEmpty) {