diff --git a/README.md b/README.md index 4aba072..6ffc8ad 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ no external dependencies (except `highlight.js`, vendored in `lib/`). - Gruvbox light/dark theme for the share, with a theme toggle in the header. - Blog index, category pages, sub-categories, tags and tag overview. +- **Article thumbnails**: each post card shows the first image of the article on the left + (max 256×256, bounded by the teaser height), summary on the right, lazy-loaded. - **Pagination**: 10 posts per page on the index and category pages, with prev/next navigation between the pages; article prev/next links stay within the article's category. - Article metadata: date, category, summary, tags, prev/next navigation, reading time. diff --git a/blog_generator.js b/blog_generator.js index 8d94d52..8550297 100644 --- a/blog_generator.js +++ b/blog_generator.js @@ -101,6 +101,15 @@ function run() { return SHARE_BASE + "/" + encodeURIComponent("tag-" + slugifyTag(t)); } + function firstImageSrc(a) { + try { + const m = String(a.getContent() || "").match(/]+src="([^"]+)"/); + return m ? m[1] : ""; + } catch (e) { + return ""; + } + } + function renderArticles(list) { const lines = []; for (const a of list) { @@ -109,6 +118,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); lines.push('
'); lines.push('
'); @@ -118,8 +128,21 @@ function run() { if (cat) lines.push(` `); lines.push(' '); lines.push('
'); - if (summary) lines.push(`

${escapeHtml(summary)}

`); - if (tags.length) { + if (summary || thumb) { + lines.push('
'); + if (thumb) { + lines.push(` '); + } + lines.push('
'); + if (summary) lines.push(`

${escapeHtml(summary)}

`); + if (tags.length) { + lines.push(' '); + } + lines.push('
'); + lines.push('
'); + } else if (tags.length) { lines.push(' '); } lines.push('
'); diff --git a/theme/blog_share_theme.css b/theme/blog_share_theme.css index e1097dc..7c27043 100644 --- a/theme/blog_share_theme.css +++ b/theme/blog_share_theme.css @@ -574,6 +574,34 @@ html.theme-light body.is-garden #content h1#title { margin-top: 1.5em; } +/* ---------- Blog post thumbnails (Bild links, Teaser rechts) ---------- */ +.blog-post-inner { + display: flex; + gap: 16px; + align-items: stretch; +} + +.blog-thumb-link { + flex: 0 0 auto; + width: min(256px, 35%); + text-decoration: none; +} + +.blog-thumb { + display: block; + width: 100%; + height: 100%; + max-height: 256px; + object-fit: cover; + border-radius: 8px; + border: 1px solid var(--background-highlight); +} + +.blog-post-body { + flex: 1; + min-width: 0; +} + .blog-post-title { margin: 0 0 0.25em; }