Update blog files and details

This commit is contained in:
prototypa
2022-08-19 03:43:12 -04:00
parent ff7d3f5555
commit 4f9e31ef39
15 changed files with 202 additions and 160 deletions

View File

@ -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>
}