diff --git a/packages/integrations/image/components/Image.astro b/packages/integrations/image/components/Image.astro index 80ab545c1..4f959f406 100644 --- a/packages/integrations/image/components/Image.astro +++ b/packages/integrations/image/components/Image.astro @@ -4,7 +4,7 @@ import loader from 'virtual:image-loader'; import { getImage } from '../src/index.js'; import type { ImageAttributes, ImageMetadata, TransformOptions, OutputFormat } from '../src/types.js'; -export interface LocalImageProps extends Omit { +export interface LocalImageProps extends Omit, Omit { src: ImageMetadata | Promise<{ default: ImageMetadata }>; } diff --git a/packages/integrations/image/components/Picture.astro b/packages/integrations/image/components/Picture.astro index 3ae82973f..762d81089 100644 --- a/packages/integrations/image/components/Picture.astro +++ b/packages/integrations/image/components/Picture.astro @@ -4,16 +4,17 @@ import Image from './Image.astro'; import loader from 'virtual:image-loader'; import { lookup } from 'mrmime'; import { getImage } from '../src/index.js'; -import type { ImageMetadata, OutputFormat } from '../src/types.js'; +import type { ImageAttributes, ImageMetadata, OutputFormat, PictureAttributes } from '../src/types.js'; -export interface Props extends Partial { +export interface Props extends Omit { src: ImageMetadata; sizes: HTMLImageElement['sizes']; widths: number[]; formats?: OutputFormat[]; + img?: Omit; } -const { src, sizes, widths, formats = ['avif', 'webp', 'jpeg'] } = Astro.props as Props; +const { src, sizes, widths, formats = ['avif', 'webp', 'jpeg'], ...attrs } = Astro.props as Props; if (widths.length <= 0) { throw new Error('At least one width must be provided for the '); @@ -39,7 +40,7 @@ const width = widths.sort().shift()!; const height = Math.round(width / aspectRatio); --- - + {sources.map(attrs => ( ))} diff --git a/packages/integrations/image/src/types.ts b/packages/integrations/image/src/types.ts index e1425965e..30ba12762 100644 --- a/packages/integrations/image/src/types.ts +++ b/packages/integrations/image/src/types.ts @@ -1,3 +1,4 @@ +import 'astro/astro-jsx.js'; export type { Image, Picture } from '../components/index.js'; export * from './index.js'; @@ -72,7 +73,8 @@ export interface TransformOptions { aspectRatio?: number | `${number}:${number}`; } -export type ImageAttributes = Partial; +export type ImageAttributes = astroHTML.JSX.HTMLAttributes; +export type PictureAttributes = astroHTML.JSX.HTMLAttributes; export interface HostedImageService { /**