All checks were successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
37 lines
1.8 KiB
TypeScript
37 lines
1.8 KiB
TypeScript
import { notFound } from 'next/navigation'
|
|
import { SectionPage } from '@/components/SectionPage'
|
|
import { getDict, isLocale, locales } from '@/i18n'
|
|
import { loadContent, loadLegal, loadProject } from '@/lib/content'
|
|
import { mediaOf, paragraphs } from '@/lib/site-model'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
type Props = { params: Promise<{ locale: string; slug: string }> }
|
|
|
|
export async function generateMetadata({ params }: Props) {
|
|
const { locale, slug } = await params
|
|
if (!isLocale(locale)) notFound()
|
|
const p = await loadProject(locale, slug)
|
|
if (!p?.title?.trim()) notFound()
|
|
return { title: `${p.title} — ${getDict(locale).siteName}`, description: p.summary || p.title, alternates: { languages: Object.fromEntries(locales.map((l) => [l, `/${l}/projects/${slug}`])) } }
|
|
}
|
|
|
|
export default async function Page({ params }: Props) {
|
|
const { locale, slug } = await params
|
|
if (!isLocale(locale)) notFound()
|
|
const t = getDict(locale)
|
|
const p = await loadProject(locale, slug)
|
|
// Проект без названия на языке страницы не показываем.
|
|
if (!p?.title?.trim()) notFound()
|
|
const { news } = await loadContent(locale)
|
|
const cover = mediaOf(p.cover)
|
|
return (
|
|
<SectionPage legal={await loadLegal(locale)} t={t} locale={locale} path={`/projects/${slug}`} title={p.title} showNews={news.length > 0}>
|
|
<article className="max-w-3xl">
|
|
{/* eslint-disable-next-line @next/next/no-img-element -- загруженные сотрудниками фото отдаёт Payload */}
|
|
{cover && <img src={cover.url} alt={cover.alt} className="h-auto w-full" />}
|
|
{paragraphs([p.summary, p.body].filter(Boolean).join('\n\n')).map((text) => <p key={text} className="mt-6 text-lg leading-relaxed">{text}</p>)}
|
|
</article>
|
|
</SectionPage>
|
|
)
|
|
}
|