mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
ef9345767b
* fix: SSR builds were hitting an undefined error and skipping the step for copying original assets * chore: update lockfile * chore: adding better error validation to getImage and getPicture * refactor: cleaning up index.ts * refactor: moving SSG build generation logic out of the integration * splitting build to ssg & ssr helpers, re-enabling SSR image build tests * sharp should automatically rotate based on EXIF * cleaning up how static images are tracked for SSG builds * undo unrelated mod.d.ts change * chore: add changeset
30 lines
779 B
Text
30 lines
779 B
Text
---
|
|
// @ts-ignore
|
|
import { getImage } from '../dist/index.js';
|
|
import type { ImageAttributes, ImageMetadata, TransformOptions, OutputFormat } from '../dist/types';
|
|
|
|
export interface LocalImageProps extends Omit<TransformOptions, 'src'>, Omit<ImageAttributes, 'src' | 'width' | 'height'> {
|
|
src: ImageMetadata | Promise<{ default: ImageMetadata }>;
|
|
}
|
|
|
|
export interface RemoteImageProps extends TransformOptions, ImageAttributes {
|
|
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>
|