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