Skip to content

Commit ae184ab

Browse files
committed
feat(share): display note icon in reference links
1 parent 1ceedf2 commit ae184ab

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

apps/server/src/share/content_renderer.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,16 @@ function handleAttachmentLink(linkEl: HTMLElement, href: string, getNote: (id: s
393393
* @param linkEl the <a> element to process.
394394
*/
395395
function cleanUpReferenceLinks(linkEl: HTMLElement) {
396+
// Note: this method is basically a reimplementation of getReferenceLinkTitleSync from the link service of the client.
396397
const noteId = linkEl.getAttribute("href")?.split("/").at(-1);
397398
const note = noteId ? shaca.getNote(noteId) : undefined;
398-
let text = "";
399399
if (!note) {
400-
text = "[missing note]";
400+
linkEl.innerHTML = "[missing note]";
401401
} else if (note.isProtected) {
402-
text = "[protected]";
402+
linkEl.innerHTML = "[protected]";
403403
} else {
404-
text = note.title;
404+
linkEl.innerHTML = `<span><span class="${note.getIcon()}"></span>${note.title}</span>`;
405405
}
406-
linkEl.innerHTML = text;
407406
}
408407

409408
/**

packages/share-theme/src/styles/content.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
height: auto;
5151
}
5252

53+
a.reference-link > span > .bx {
54+
margin-inline-end: 3px;
55+
}
56+
5357
body:not(.math-loaded) .math-tex {
5458
visibility: hidden;
5559
}

0 commit comments

Comments
 (0)