import { notFound } from 'next/navigation'; import type { SectionRecord } from '$entities/Section'; import { getCollection } from '$shared/api'; import { SectionFactory } from '$widgets/SectionFactory'; import { SectionsAccordion } from '$widgets/SectionsAccordion'; /** * Optional catchall: `/` → first section, `/:slug` → that section. */ export async function generateStaticParams() { const { items: sections } = await getCollection('sections', { sort: 'order', tags: ['sections'], }); return [{}, ...sections.map((s) => ({ slug: [s.slug] }))]; } type Props = { params: Promise<{ slug?: string[] }>; }; /** * Portfolio page — one route per section, sections list always visible. */ export default async function SectionPage({ params }: Props) { const { slug } = await params; const { items: sections } = await getCollection('sections', { sort: 'order', tags: ['sections'], }); if (sections.length === 0) { notFound(); } const activeSlug = slug?.[0] ?? sections[0].slug; if (!sections.some((s) => s.slug === activeSlug)) { notFound(); } return (
{sections.map((s) => ( ))}
); }