Thumbnails: accept thumb.<ext> or *_thumb.<ext> child notes, auto-hide them from menu (shareHiddenFromTree), keep first-image fallback
This commit is contained in:
+15
-1
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user