Skip to content

Commit 006b797

Browse files
committed
Attempt to use Image component instead of img on homepage
1 parent 3540b73 commit 006b797

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/components/Image/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type Props = ComponentProps<typeof Image> & {
99
const { props } = Astro;
1010
---
1111

12-
<div class="relative w-fit h-fit">
12+
<div class={props.containerClass || "relative w-fit h-fit"}>
1313
<!-- The props are identical but the lack of "IntrinsicAttributes" gives an errant ts error -->
1414
<!-- @ts-ignore -->
1515
<Image

src/components/PageHeader/HomePage.astro

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import Image from "@components/Image/index.astro";
23
import type { CollectionEntry } from "astro:content";
34
import { Icon } from "../Icon";
45
@@ -32,20 +33,14 @@ const { config } = Astro.props;
3233

3334
{
3435
config.data.heroImages.map((im, i) => (
35-
<div class={`relative hero-image-container ${i > 0 ? "hidden" : ""}`}>
36-
<img
37-
class={"hero-image"}
38-
src={im.image.src}
39-
alt={im.altText}
40-
loading={i > 0 ? "lazy" : "eager"}
41-
/>
42-
<p
43-
aria-hidden
44-
class={"renderable-alt bg-bg-gray-40 line-clamp-3 absolute top-0 mt-sm mx-sm px-[7.5px] pb-[2.5px] rounded-xl text-body-caption text-ellipsis"}
45-
>
46-
{im.altText}
47-
</p>
48-
</div>
36+
<Image
37+
containerClass={`relative hero-image-container ${i > 0 ? "hidden" : ""}`}
38+
class={"hero-image"}
39+
aspectRatio="none"
40+
src={im.image}
41+
alt={im.altText}
42+
loading={i > 0 ? "lazy" : "eager"}
43+
/>
4944
))
5045
}
5146
</div>
@@ -56,7 +51,6 @@ const { config } = Astro.props;
5651
const images = document.querySelectorAll(".hero-image-container");
5752
if (images.length > 1) {
5853
const shownImageInd = Math.round(Math.random() * (images.length - 1));
59-
console.log(shownImageInd);
6054
// hide the default one
6155
images[0].classList.add("hidden");
6256
// show a random one

0 commit comments

Comments
 (0)