Skip to content

Commit

Permalink
docs: fix astro solution
Browse files Browse the repository at this point in the history
  • Loading branch information
dawaltconley committed Jun 20, 2024
1 parent 56ac6db commit ad0156d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions solutions/astro.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export interface Props extends HTMLAttributes<'picture'>, ImageOptions {
src: string;
alt: string;
sizes: string
imgProps?: HTMLAttributes<'img'>;
imgProps?: Omit<HTMLAttributes<'img'>, 'sizes' | 'class:list'>
}
const { src, alt, sizes, widths, formats, imgProps, ...pictureProps } =
Expand All @@ -96,9 +96,13 @@ const images = new ResponsiveImages({
disable: !import.meta.env.PROD,
});
const imgOptions: ImageOptions = {}
if (widths) imgOptions.widths = widths
if (formats) imgOptions.formats = formats
const sources = await images
.responsive(src)
.fromSizes(sizes, { widths, formats })
.fromSizes(sizes, imgOptions)
.toSources({ ...imgProps, alt })
---
Expand Down

0 comments on commit ad0156d

Please sign in to comment.