From 9921d3e0a75588c6500f6167227cd5169106b3b8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 26 Sep 2025 18:42:59 +0300 Subject: [PATCH] feat(share): render included notes --- apps/server/src/share/content_renderer.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/server/src/share/content_renderer.ts b/apps/server/src/share/content_renderer.ts index c1c16e48d..c12e7887f 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) {