Thumbnails: accept thumb.<ext> or *_thumb.<ext> child notes, auto-hide them from menu (shareHiddenFromTree), keep first-image fallback
This commit is contained in:
@@ -51,10 +51,12 @@ CSS file (Gruvbox, light + dark, theme toggle without reload).
|
||||
- **Dates**: all visible dates (post cards, garden table) are rendered by the generator's
|
||||
`dateText()` helper as `Fri 2026-08-28` (English weekday + ISO date); `blog_data.date`
|
||||
stays ISO for sorting, `blog_data.dateText` is added for display. JSON-LD keeps ISO dates.
|
||||
- **Thumbnails** (`thumbSrc()`): prefer a child note of the article titled `*_thumb.*`
|
||||
(e.g. `ngc281_thumb.jpg`) → `api/notes/<id>/download`; otherwise use the first `<img>`
|
||||
from the note content. Layout: image left, summary right (`.blog-post-inner`),
|
||||
`max-height:256px`, lazy-loaded. **There is no server-side resizing** – see "Limitations".
|
||||
- **Thumbnails** (`thumbSrc()`): prefer a child note of the article titled `thumb.<ext>` **or**
|
||||
`*_thumb.<ext>` (e.g. `thumb.png`, `ngc281_thumb.jpg`) → `api/notes/<id>/download`; otherwise
|
||||
use the first `<img>` from the note content. Layout: image left, summary right (`.blog-post-inner`),
|
||||
`max-height:256px`, lazy-loaded. The generator auto-sets `shareHiddenFromTree` on matching
|
||||
thumb child notes so they never appear in the blog menu. **There is no server-side resizing** –
|
||||
see "Limitations".
|
||||
- Regenerates `feed.xml`, `sitemap.xml`, `state_map` (garden states) and `blog_data`
|
||||
(search index: id/title/url/summary/tags/category). Sets `shareDescription` from `summary`.
|
||||
|
||||
|
||||
+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