/** * Catch-all route — handles both subpage listings and album detail pages. * * Single segment: * - If slug matches a subpage → render subpage album grid * - If slug matches a standalone album → render album detail * * Two segments: * - Treat as subpage-slug/album-slug → render album detail * with back-link to the subpage */ import Link from 'next/link'; import { immich } from '@/lib/immich'; import { notFound } from 'next/navigation'; import { PhotoGrid } from './PhotoGrid'; import { imageUrl, exifUrl } from '@/lib/urls'; // Render at request time — requires live Immich connection export const dynamic = 'force-dynamic'; interface PathPageProps { params: Promise<{ path: string[] }>; } export default async function PathPage({ params }: PathPageProps) { const { path } = await params; if (!path || path.length === 0) { notFound(); } // ── Two segments: subpage/album ────────────────────────────── if (path.length === 2) { const [subpageSlug, albumSlug] = path; const album = await immich.getAlbumBySlug(albumSlug, subpageSlug); if (!album) { notFound(); } // Get subpage name for the back link const subpageData = await immich.getSubpageAlbums(subpageSlug); const subpageName = subpageData?.subpage.name ?? subpageSlug; const images = album.assets.filter((asset) => asset.type === 'IMAGE'); return ( <>
{images.length} {images.length === 1 ? 'photo' : 'photos'} {album.description && ` · ${album.description}`}
{images.length} {images.length === 1 ? 'photo' : 'photos'} {album.description && ` · ${album.description}`}