mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
33 lines
825 B
Text
33 lines
825 B
Text
---
|
|
// @ts-ignore
|
|
import { getImage } from '../dist/index.js';
|
|
import type { ImgHTMLAttributes } from './index.js';
|
|
import type { ImageMetadata, TransformOptions, OutputFormat } from '../dist/index.js';
|
|
|
|
interface LocalImageProps
|
|
extends Omit<TransformOptions, 'src'>,
|
|
Omit<ImgHTMLAttributes, 'src' | 'width' | 'height'> {
|
|
src: ImageMetadata | Promise<{ default: ImageMetadata }>;
|
|
}
|
|
|
|
interface RemoteImageProps extends TransformOptions, astroHTML.JSX.ImgHTMLAttributes {
|
|
src: string;
|
|
format: OutputFormat;
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
export type Props = LocalImageProps | RemoteImageProps;
|
|
|
|
const { loading = 'lazy', decoding = 'async', ...props } = Astro.props as Props;
|
|
|
|
const attrs = await getImage(props);
|
|
---
|
|
|
|
<img {...attrs} {loading} {decoding} />
|
|
|
|
<style>
|
|
img {
|
|
content-visibility: auto;
|
|
}
|
|
</style>
|