Update blog files and details
This commit is contained in:
@ -6,7 +6,7 @@ const {
|
||||
alt,
|
||||
sizes,
|
||||
widths,
|
||||
aspectRatio,
|
||||
aspectRatio = 1,
|
||||
formats = ["avif", "webp"],
|
||||
loading = "lazy",
|
||||
decoding = "async",
|
||||
@ -14,22 +14,32 @@ const {
|
||||
...attrs
|
||||
} = Astro.props;
|
||||
|
||||
const { image, sources = [] } =
|
||||
!src ? { image: {}}
|
||||
: (typeof src === "string"
|
||||
? { image: { src } }
|
||||
:
|
||||
await getPicture({
|
||||
src,
|
||||
widths,
|
||||
formats,
|
||||
aspectRatio,
|
||||
}))
|
||||
// const { image, sources = [] } =
|
||||
// !src ? { image: {}}
|
||||
// : (typeof src === "string"
|
||||
// ? { image: { src } }
|
||||
// :
|
||||
|
||||
let picture = null;
|
||||
try {
|
||||
picture = await getPicture({
|
||||
src,
|
||||
widths,
|
||||
formats,
|
||||
aspectRatio,
|
||||
})
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
const { image = {}, sources = [] } = picture || {}
|
||||
---
|
||||
|
||||
{ (src || !image) &&
|
||||
{ (src && image?.src) &&
|
||||
<picture {...attrs}>
|
||||
{sources.map((attrs) => <source {...attrs} {sizes} />)}
|
||||
{sources.map((attrs) =>
|
||||
<source {...attrs} {sizes} />)}
|
||||
<img {...image} {loading} {decoding} {alt} class={className} />
|
||||
</picture>
|
||||
}
|
||||
|
Reference in New Issue
Block a user