From 14842127da78214c200bdac1e5285d355b9b5f53 Mon Sep 17 00:00:00 2001 From: jay Date: Sat, 30 May 2026 22:39:22 +0000 Subject: [PATCH] Fix ArticleCard image fallback, build warning, and link safety MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Show the typographic fallback for missing images too (not only on load error), driven by component state instead of imperative class mutation — which also clears the unused-CSS-selector build warning. - Only render external links for http(s) URLs, else href=#. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/lib/components/ArticleCard.svelte | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/frontend/src/lib/components/ArticleCard.svelte b/frontend/src/lib/components/ArticleCard.svelte index 94d94ec..cb4559d 100644 --- a/frontend/src/lib/components/ArticleCard.svelte +++ b/frontend/src/lib/components/ArticleCard.svelte @@ -1,18 +1,28 @@
- - {#if article.image_url} + + {#if article.image_url && imgOk} e.currentTarget.parentElement.classList.add('noimg')} /> + onerror={() => (imgOk = false)} /> + {:else} + {article.topic ?? 'good news'} {/if} - {article.topic ?? 'good news'}
@@ -22,7 +32,7 @@ {article.source}
-

{article.title}

+

{article.title}

{#if hero && article.description}

{article.description}

@@ -59,13 +69,11 @@ } .media img { width: 100%; height: 100%; object-fit: cover; } .fallback { - position: absolute; inset: 0; display: none; + position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; - font-family: var(--serif); font-style: italic; color: var(--sage-deep); opacity: 0.6; - text-transform: lowercase; letter-spacing: 0.02em; + font-family: var(--serif); font-style: italic; color: var(--sage-deep); opacity: 0.5; + text-transform: lowercase; letter-spacing: 0.02em; font-size: 1.1rem; } - .media.noimg img { display: none; } - .media.noimg .fallback { display: flex; } .body { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; } .tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.74rem; }