Thumbnails: prefer *_thumb child note, fallback to first image; round embedded images and inline code; theme figcaptions

This commit is contained in:
trilium-share-gruvbox
2026-08-28 14:46:47 +02:00
parent 9a20dfa2e1
commit 302e48391c
3 changed files with 26 additions and 3 deletions
+6 -2
View File
@@ -101,7 +101,11 @@ function run() {
return SHARE_BASE + "/" + encodeURIComponent("tag-" + slugifyTag(t));
}
function firstImageSrc(a) {
function thumbSrc(a) {
try {
const thumbs = (a.getChildNotes() || []).filter(n => /_thumb\.[A-Za-z0-9]+$/i.test(n.title));
if (thumbs.length) return "api/notes/" + thumbs[0].noteId + "/download";
} catch (e) {}
try {
const m = String(a.getContent() || "").match(/<img[^>]+src="([^"]+)"/);
return m ? m[1] : "";
@@ -118,7 +122,7 @@ function run() {
const summary = a.getLabelValue("summary") || "";
const link = `${SHARE_BASE}/${encodeURIComponent(a.getLabelValue("shareAlias") || a.noteId)}`;
const tags = tagList(a);
const thumb = firstImageSrc(a);
const thumb = thumbSrc(a);
lines.push('<article class="blog-post">');
lines.push(' <header class="blog-post-header">');