17 lines
715 B
Plaintext
17 lines
715 B
Plaintext
---
|
|
import { Image } from 'astro:assets';
|
|
import type { ImageMetadata } from 'astro';
|
|
import { resolveContent } from '../../lib/content';
|
|
interface Props {
|
|
tag: string; src: ImageMetadata; alt: string;
|
|
class?: string; loading?: 'lazy' | 'eager'; widths?: number[]; sizes?: string; height?: number;
|
|
}
|
|
const { tag, src, alt, class: cls, ...rest } = Astro.props;
|
|
const c = resolveContent(tag);
|
|
const override = c.type === 'image' && c.value ? `/uploads/${c.value}` : null;
|
|
const guid = c.guid || undefined;
|
|
---
|
|
{override
|
|
? <img src={override} alt={alt} class={cls} data-tag={tag} data-guid={guid} loading={rest.loading} />
|
|
: <Image src={src} alt={alt} class={cls} data-tag={tag} data-guid={guid} {...rest} />}
|