Skip to content

Build your personal knowledge base with Trilium Notes

feat(share): display note icon in reference links

Elian Doranae184ab89451
diff --git a/apps/server/src/share/content_renderer.ts b/apps/server/src/share/content_renderer.ts
index dc9fac8ce9..2548291149 100644
--- a/apps/server/src/share/content_renderer.ts
+++ b/apps/server/src/share/content_renderer.ts
@@ -393,17 +393,16 @@ function handleAttachmentLink(linkEl: HTMLElement, href: string, getNote: (id: s
* @param linkEl the <a> element to process.
*/
function cleanUpReferenceLinks(linkEl: HTMLElement) {
+ // Note: this method is basically a reimplementation of getReferenceLinkTitleSync from the link service of the client.
const noteId = linkEl.getAttribute("href")?.split("/").at(-1);
const note = noteId ? shaca.getNote(noteId) : undefined;
- let text = "";
if (!note) {
- text = "[missing note]";
+ linkEl.innerHTML = "[missing note]";
} else if (note.isProtected) {
- text = "[protected]";
+ linkEl.innerHTML = "[protected]";
} else {
- text = note.title;
+ linkEl.innerHTML = `<span><span class="${note.getIcon()}"></span>${note.title}</span>`;
}
- linkEl.innerHTML = text;
}
/**
diff --git a/packages/share-theme/src/styles/content.css b/packages/share-theme/src/styles/content.css
index 0749e7d098..0f7a6430c2 100644
--- a/packages/share-theme/src/styles/content.css
+++ b/packages/share-theme/src/styles/content.css
@@ -50,6 +50,10 @@
height: auto;
}
+a.reference-link > span > .bx {
+ margin-inline-end: 3px;
+}
+
body:not(.math-loaded) .math-tex {
visibility: hidden;
}