mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
fix(site): handle remote image URLs in Img component (#789)
This commit is contained in:
@@ -5,8 +5,16 @@ import type { ComponentProps } from 'astro/types';
|
||||
import { twMerge } from '@/utils/twMerge';
|
||||
|
||||
type Props = ComponentProps<typeof Image>;
|
||||
const { class: className, ...rest } = Astro.props;
|
||||
const { class: className, src, ...rest } = Astro.props;
|
||||
|
||||
const isRemote = typeof src === 'string' && src.startsWith('http');
|
||||
---
|
||||
|
||||
{/* @ts-expect-error tbh I don't know how to tell ts that inferSize is ok */}
|
||||
<Image class={twMerge("my-8", className)} inferSize {...rest} />
|
||||
{
|
||||
isRemote ? (
|
||||
<img class={twMerge("my-8", className)} src={src} {...rest} />
|
||||
) : (
|
||||
// @ts-expect-error tbh I don't know how to tell ts that inferSize is ok
|
||||
<Image class={twMerge("my-8", className)} inferSize src={src} {...rest} />
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user