Components folder refactoring

This commit is contained in:
prototypa
2022-08-17 22:36:36 -04:00
parent d7a960995d
commit 3369de84f3
28 changed files with 465 additions and 156 deletions

View File

@ -0,0 +1,41 @@
---
import { getPicture } from "@astrojs/image";
const {
src,
alt,
sizes,
widths,
aspectRatio,
formats = ["avif", "webp"],
loading = "lazy",
decoding = "async",
class: className = "",
...attrs
} = Astro.props;
const { image, sources = [] } =
!src ? { image: {}}
: (typeof src === "string"
? { image: { src } }
:
await getPicture({
src,
widths,
formats,
aspectRatio,
}))
---
{ (src || !image) &&
<picture {...attrs}>
{sources.map((attrs) => <source {...attrs} {sizes} />)}
<img {...image} {loading} {decoding} {alt} class={className} />
</picture>
}
<style>
img {
content-visibility: auto;
}
</style>