Thumbnails: accept thumb.<ext> or *_thumb.<ext> child notes, auto-hide them from menu (shareHiddenFromTree), keep first-image fallback

This commit is contained in:
trilium-share-gruvbox
2026-08-28 20:41:54 +02:00
parent af584101eb
commit e224dea9aa
2 changed files with 21 additions and 5 deletions
+15 -1
View File
@@ -103,7 +103,7 @@ function run() {
function thumbSrc(a) {
try {
const thumbs = (a.getChildNotes() || []).filter(n => /_thumb\.[A-Za-z0-9]+$/i.test(n.title));
const thumbs = (a.getChildNotes() || []).filter(n => /^(?:thumb|.+_thumb)\.[A-Za-z0-9]+$/i.test(n.title));
if (thumbs.length) return "api/notes/" + thumbs[0].noteId + "/download";
} catch (e) {}
try {
@@ -598,6 +598,19 @@ function run() {
}
}
function hideThumbChildren() {
for (const a of articles) {
try {
for (const c of a.getChildNotes()) {
if (/^(?:thumb|.+_thumb)\.[A-Za-z0-9]+$/i.test(c.title) && !c.hasLabel("shareHiddenFromTree")) {
c.setLabel("shareHiddenFromTree", "");
c.save();
}
}
} catch (e) {}
}
}
buildIndex();
const systemNote = api.getNote(BLOG_SYSTEM_NOTE_ID);
@@ -617,5 +630,6 @@ function run() {
buildSitemap();
ensureSeoMeta();
buildBlogData();
hideThumbChildren();
removeEmptyCategories();
}