mirror of
https://github.com/KazooTTT/kazoottt-blog.git
synced 2025-06-23 02:31:33 +08:00
Allowed card images to be optional
This commit is contained in:
@ -15,8 +15,11 @@ const {
|
||||
imageClass
|
||||
} = Astro.props
|
||||
const images = import.meta.glob<{ default: ImageMetadata }>('/src/assets/*.{jpeg,jpg,png,gif}')
|
||||
if (!images[imagePath])
|
||||
throw new Error(`"${imagePath}" does not exist in glob: "src/assets/*.{jpeg,jpg,png,gif}"`)
|
||||
|
||||
if (imagePath) {
|
||||
if (!images[imagePath])
|
||||
throw new Error(`"${imagePath}" does not exist in glob: "src/assets/*.{jpeg,jpg,png,gif}"`)
|
||||
}
|
||||
---
|
||||
|
||||
<Tag
|
||||
@ -27,12 +30,16 @@ if (!images[imagePath])
|
||||
)}
|
||||
href={href}
|
||||
>
|
||||
<Image
|
||||
src={images[imagePath]()}
|
||||
alt={altText}
|
||||
class={cn('mb-3 md:absolute md:mb-0', imageClass)}
|
||||
loading='eager'
|
||||
/>
|
||||
{
|
||||
imagePath && (
|
||||
<Image
|
||||
src={images[imagePath]()}
|
||||
alt={altText}
|
||||
class={cn('mb-3 md:absolute md:mb-0', imageClass)}
|
||||
loading='eager'
|
||||
/>
|
||||
)
|
||||
}
|
||||
<div class='flex flex-col gap-y-1.5'>
|
||||
<div class='flex flex-col gap-y-0.5'>
|
||||
<h1 class='text-lg font-medium'>{heading}</h1>
|
||||
|
Reference in New Issue
Block a user