import Link from 'next/link' import { notFound } from 'next/navigation' import { getDict, isLocale, locales } from '@/i18n' import { loadNews } from '@/lib/content' import { visibleNews } from '@/lib/news-model' import { SectionPage } from '@/components/SectionPage' export const dynamic = 'force-dynamic' import { safeWebUrl } from '@/lib/news-model' import Image from 'next/image' import { cache } from 'react' const findNews = cache(async (locale: 'ru' | 'kk' | 'en', id: string) => visibleNews(await loadNews(locale)).find(n => String(n.id) === id)) export async function generateMetadata({ params }: { params: Promise<{ locale: string; id: string }> }) { const { locale, id } = await params if (!isLocale(locale)) notFound() const n = await findNews(locale, id) if (!n) notFound() return { title: `${n.title} — ${getDict(locale).siteName}`, description: n.summary || n.title, alternates: { languages: Object.fromEntries(locales.map(l => [l, `/${l}/news/${id}`])) } } } export default async function Page({ params }: { params: Promise<{ locale: string; id: string }> }) { const { locale, id } = await params if (!isLocale(locale)) notFound() const t = getDict(locale) const n = await findNews(locale, id) if (!n) notFound() const image = safeWebUrl(n.imageUrl) const source = safeWebUrl(n.sourceUrl) return
{n.place &&

{n.place}

} {image && {n.title}} {(n.body || n.summary || t.tbc).split(/\n\s*\n/).map((text, index) =>

{text}

)} {source &&

{t.sections.source}

} {t.news.title}
}