qazaq-legacy-foundation-web/src/app/(site)/[locale]/projects/page.tsx
Peppa 1a58c2a4d9
All checks were successful
peppa/lint lint: success за 1с
peppa/typecheck typecheck: success за 2с
peppa/test test: success за 1с
peppa/build build: success за 41с
ci / checks (pull_request) Successful in 1m22s
deploy / deploy (pull_request) Successful in 17s
QLFW-6: панель управления: проекты, фото, контакты и текст «О фонде»
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 23:33:54 +05:00

36 lines
2.7 KiB
TypeScript

import { notFound } from 'next/navigation'
import { getDict, isLocale, locales } from '@/i18n'
import { loadContent, loadLegal, loadProjects } from '@/lib/content'
import { mediaOf, visibleProjects } from '@/lib/site-model'
import { buildHomeModel } from '@/lib/home-model'
import { SectionPage } from '@/components/SectionPage'
import Image from 'next/image'
import Link from 'next/link'
export const dynamic = 'force-dynamic'
export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
const { locale } = await params
if (!isLocale(locale)) notFound()
const t = getDict(locale)
return { title: `${t.projects.title} — ${t.siteName}`, description: t.metaDescription, alternates: { languages: Object.fromEntries(locales.map(l => [l, `/${l}/projects`])) } }
}
export default async function Page({ params }: { params: Promise<{ locale: string }> }) {
const { locale } = await params
if (!isLocale(locale)) notFound()
const t = getDict(locale)
const { home, news } = await loadContent(locale)
const m = buildHomeModel(home, news, t)
const projects = visibleProjects(await loadProjects(locale))
return <SectionPage legal={await loadLegal(locale)} t={t} locale={locale} path="/projects" title={t.projects.title} showNews={m.news.length > 0}>
<article className="grid gap-8 border border-line p-6 sm:p-10 md:grid-cols-[1fr_2fr]">
<Link href={`/${locale}/projects/ermek-serkebayev`}><Image src="/books/serkebayev/cover.jpg" alt={t.book.cover} width={677} height={1000} sizes="(min-width: 768px) 320px, 100vw" className="mx-auto h-auto w-full max-w-sm" /></Link>
<div className="min-w-0"><p>{t.book.author}</p><h2 className="mt-3 font-serif text-2xl sm:text-3xl">{t.book.title}</h2>{t.book.paragraphs.map(text => <p key={text} className="mt-5">{text}</p>)}<Link href={`/${locale}/projects/ermek-serkebayev`} className="mt-6 inline-flex min-h-11 items-center underline underline-offset-4">{t.projects.more}</Link></div>
</article>
{projects.length > 0 && <ul className="mt-8 grid gap-6 sm:grid-cols-2 lg:grid-cols-3">{projects.map(p => { const cover = mediaOf(p.cover); return <li key={p.id} className="border border-line p-6">
{/* eslint-disable-next-line @next/next/no-img-element -- загруженные сотрудниками фото отдаёт Payload */}
{cover && <Link href={`/${locale}/projects/${p.slug}`}><img src={cover.url} alt={cover.alt} loading="lazy" className="mb-5 h-auto w-full" /></Link>}
<h2 className="font-serif text-2xl">{p.title}</h2>{p.summary && <p className="mt-3">{p.summary}</p>}
<Link href={`/${locale}/projects/${p.slug}`} className="mt-5 inline-flex min-h-11 items-center underline underline-offset-4">{t.projects.more}</Link></li> })}</ul>}
</SectionPage>
}