import type { Metadata } from 'next'; import { getTranslations } from 'next-intl/server'; import { notFound } from 'next/navigation'; import { resolvePageRenderData } from '#web-runtime/api/render-data'; import { pageMetadata } from '#web-runtime/lib/page-metadata'; import PageRenderer from '#web-runtime/renderer'; import { getPathname } from '#i18n/navigation'; import { routing } from '#i18n/routing'; interface PageRouteProps { params: Promise<{ locale: string; path?: string[]; }>; searchParams: Promise>; } function routePath(path?: string[]): string { return path?.join('/') ?? ''; } function publicPath(locale: string, path: string): string { return getPathname({ locale, href: path ? `/${path}` : '/' }); } export async function generateMetadata({ params }: PageRouteProps): Promise { const { locale, path } = await params; const data = await resolvePageRenderData(locale, routePath(path)); if (!data) { const t = await getTranslations({ locale, namespace: 'Pages.NotFoundPage' }); return { title: t('metaTitle') }; } return pageMetadata(data, routing.defaultLocale, publicPath); } export default async function PublicPage({ params, searchParams }: PageRouteProps) { const { locale, path } = await params; const data = await resolvePageRenderData(locale, routePath(path)); if (!data) { notFound(); } return ; }