import Link from 'next/link'; import Image from 'next/image'; import { imageUrl } from '@/lib/urls'; import { SubpageSectionConfig } from '@/lib/config'; interface SubpageAlbum { id: string; slug: string; albumName: string; assetCount: number; albumThumbnailAssetId: string | null; } interface Placeholder { blurDataURL?: string; dominantColor?: string; } interface SubpageGridViewProps { slug: string; title?: string; subtitle?: string; albums: SubpageAlbum[]; coverPlaceholders: (Placeholder | null)[]; sections?: SubpageSectionConfig[]; } function AlbumGrid({ albums, albumMap, placeholderMap, slug, }: { albums: SubpageAlbum[]; albumMap: Map; placeholderMap: Map; slug: string; }) { return (
{albums.map((album) => { const ph = placeholderMap.get(album.id) ?? null; return ( {album.albumThumbnailAssetId ? ( {album.albumName} ) : (
)} {album.assetCount} {album.assetCount === 1 ? 'photo' : 'photos'}
{album.albumName} {album.assetCount} {album.assetCount === 1 ? 'photo' : 'photos'}
); })}
); } export function SubpageGridView({ slug, title, subtitle, albums, coverPlaceholders, sections }: SubpageGridViewProps) { // Build lookup maps once const albumMap = new Map(albums.map((a) => [a.id, a])); const placeholderMap = new Map(albums.map((a, i) => [a.id, coverPlaceholders[i] ?? null])); const hasSections = sections && sections.length > 0; return (
{(title || subtitle) && (
{title &&

{title}

} {subtitle &&

{subtitle}

}
)} {/* Typographic Table of Contents */} {hasSections && ( )} {/* Sectioned layout */} {hasSections ? ( sections.map((sec) => { const sectionAlbums = sec.albumIds .map((id) => albumMap.get(id)) .filter(Boolean) as SubpageAlbum[]; return (

{sec.title}

{sec.description && (

{sec.description}

)}
); }) ) : ( /* Flat layout (no sections) */ )}
); }