/** * Map page — server component shell for the interactive map. * Loads Leaflet CSS, renders the MapView client component. */ import { getConfig } from '@/lib/config'; import { visibleMapCounts } from '@/lib/mapService'; import { isAuthenticated } from '@/lib/auth'; import { cookies } from 'next/headers'; import { notFound } from 'next/navigation'; import { MapView } from '@/components/MapView'; import { BackLink } from '@/components/BackLink'; import type { Metadata } from 'next'; import { getServerDictionary } from '@/lib/i18n/server'; // Imported here as well as in LeafletMap: this page has the stylesheet in its // server HTML, so the tiles never render before their CSS. import 'leaflet/dist/leaflet.css'; import './map.css'; export const dynamic = 'force-dynamic'; export function generateMetadata(): Metadata { return { title: getServerDictionary().map.title }; } export default async function MapPage() { const config = getConfig(); const t = getServerDictionary(); if (!config.map) { notFound(); } // Counts what the map may show this viewer: a hidden subpage is reachable // by direct link only, and a password-protected subpage or album the // viewer has not unlocked is dropped by /api/map — neither is counted. const cookieStore = await cookies(); const { collections: collectionCount, albums: albumCount } = visibleMapCounts( config, (key, type) => isAuthenticated(key, (name) => cookieStore.get(name)?.value, type), ); return ( <>
{t.map.subtitle}