Skip to content

Commit a416c5a

Browse files
committed
feat(gallery): eager load first 10 images
1 parent 8714baf commit a416c5a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/components/Gallery.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface GalleryImage {
77
src: string
88
alt: string
99
aspectRatio: number
10+
lazy: boolean
1011
}
1112
</script>
1213

@@ -29,12 +30,12 @@ export interface GalleryImage {
2930
<img
3031
:src="image.src"
3132
:alt="image.alt"
32-
loading="lazy"
33+
:loading="image.lazy ? 'lazy' : 'eager'"
3334
decoding="async"
3435
oncontextmenu="return false"
3536
ondragstart="return false"
3637
on-touchstart="return false"
37-
class="w-full shadow-2xl"
38+
class="w-full select-none shadow-2xl"
3839
>
3940
</div>
4041
</MasonryWall>

src/pages/photography.astro

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function getAltFromFilename(filename: string): string {
1717
return filename.substring(start, end).replace(/-/g, ' ')
1818
}
1919
20-
const processedImages = rawImages.map(async (rawImage) => {
20+
const processedImages = rawImages.map(async (rawImage, index) => {
2121
const alt = getAltFromFilename(rawImage.src)
2222
const {
2323
src,
@@ -27,6 +27,7 @@ const processedImages = rawImages.map(async (rawImage) => {
2727
src,
2828
alt,
2929
aspectRatio: width / height,
30+
lazy: index >= 10,
3031
}
3132
})
3233

0 commit comments

Comments
 (0)