Files
personal-site/src/components/Captures.astro
T
2026-11-02 16:36:00 -05:00

39 lines
2.1 KiB
Plaintext

---
import { Image } from 'astro:assets';
const found = import.meta.glob<{ default: ImageMetadata }>('../assets/images/photography/*.{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);
const corner = "before:absolute before:size-[22px] before:border-accent before:content-[''] after:absolute after:size-[22px] after:border-accent after:content-['']";
const shot = (photo: boolean) => [
'relative m-0 overflow-hidden border border-line bg-panel',
!photo && `${corner} before:top-2.5 before:left-2.5 before:border-t-2 before:border-l-2 after:right-2.5 after:bottom-2.5 after:border-r-2 after:border-b-2`,
];
const caption = 'absolute inset-x-0 bottom-0 px-5 pt-[18px] pb-3 font-mono text-[12px]';
const captionPhoto = 'bg-[linear-gradient(transparent,rgba(5,8,7,0.85))] text-fg';
---
<div class="flex flex-wrap gap-3">
<figure class:list={[shot(!!slots[0]), 'h-[372px] min-w-0 flex-[2_1_360px] max-sm:h-[260px]']}>
{slots[0] ? <Image class="absolute inset-0 size-full object-cover" src={slots[0].src} alt={slots[0].caption} widths={[640, 1000, 1400]} sizes="(max-width: 900px) 100vw, 700px" /> : null}
<figcaption class:list={[caption, slots[0] ? captionPhoto : 'text-muted']}>{slots[0] ? slots[0].caption : '[PHOTO 1 · FEATURED]'}</figcaption>
</figure>
<div class="flex min-w-0 flex-[1_1_220px] flex-col gap-3">
{
[1, 2].map((i) => (
<figure class:list={[shot(!!slots[i]), 'h-[180px]']}>
{slots[i] ? <Image class="absolute inset-0 size-full object-cover" src={slots[i]!.src} alt={slots[i]!.caption} widths={[400, 700]} sizes="(max-width: 900px) 100vw, 350px" /> : null}
<figcaption class:list={[caption, slots[i] ? captionPhoto : 'text-muted']}>{slots[i] ? slots[i]!.caption : `[PHOTO ${i + 1}]`}</figcaption>
</figure>
))
}
</div>
</div>