This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
---
|
||||
import { Image } from 'astro:assets';
|
||||
|
||||
const found = import.meta.glob<{ default: ImageMetadata }>('../assets/photos/*.{jpg,jpeg,png,webp,avif}', { eager: true });
|
||||
const photos = Object.entries(found)
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.slice(0, 3)
|
||||
.map(([path, mod]) => ({
|
||||
src: mod.default,
|
||||
caption: (path.split('/').pop() ?? '').replace(/\.[^.]+$/, '').replace(/[-_]+/g, ' ').toUpperCase(),
|
||||
}));
|
||||
const slots = [0, 1, 2].map((i) => photos[i] ?? null);
|
||||
---
|
||||
|
||||
<div class="captures">
|
||||
<figure class:list={['shot big', slots[0] ? 'photo' : 'empty']}>
|
||||
{slots[0] ? <Image src={slots[0].src} alt={slots[0].caption} widths={[640, 1000, 1400]} sizes="(max-width: 900px) 100vw, 700px" /> : null}
|
||||
<figcaption>{slots[0] ? slots[0].caption : '[PHOTO 1 · FEATURED]'}</figcaption>
|
||||
</figure>
|
||||
<div class="side">
|
||||
{
|
||||
[1, 2].map((i) => (
|
||||
<figure class:list={['shot', slots[i] ? 'photo' : 'empty']}>
|
||||
{slots[i] ? <Image src={slots[i]!.src} alt={slots[i]!.caption} widths={[400, 700]} sizes="(max-width: 900px) 100vw, 350px" /> : null}
|
||||
<figcaption>{slots[i] ? slots[i]!.caption : `[PHOTO ${i + 1}]`}</figcaption>
|
||||
</figure>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user