From 683224c51a582d5f57da2529b0a2a700e50eddb3 Mon Sep 17 00:00:00 2001 From: Tadas Petra Date: Tue, 4 Jun 2024 09:21:13 -0500 Subject: [PATCH] fix images --- src/components/ArticleCard.astro | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/ArticleCard.astro b/src/components/ArticleCard.astro index f1040ca..aaec84d 100644 --- a/src/components/ArticleCard.astro +++ b/src/components/ArticleCard.astro @@ -2,6 +2,15 @@ import { Image } from "astro:assets"; const { article } = Astro.props; + +const images = import.meta.glob<{ default: ImageMetadata }>( + "/src/assets/*.{jpeg,jpg,png,gif}" +); +const image = images[article.data.image](); +if (!image) + throw new Error( + `"${article.data.image}" does not exist in glob: "src/assets/*.{jpeg,jpg,png,gif}"` + ); ---
@@ -10,11 +19,9 @@ const { article } = Astro.props; class="rounded-lg p-4 hover:bg-gray-100 flex" >

{article.data.title}