All checks were successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
3.1 KiB
TypeScript
40 lines
3.1 KiB
TypeScript
import { notFound } from 'next/navigation'
|
|
import { getDict, isLocale, locales } from '@/i18n'
|
|
import { loadContent, loadLegal, loadProjects, loadSettings } from '@/lib/content'
|
|
import { bookPhotoList, mediaOf, visibleProjects } from '@/lib/site-model'
|
|
import { buildHomeModel } from '@/lib/home-model'
|
|
import { PhotoGallery } from '@/components/PhotoGallery'
|
|
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))
|
|
const base = [1, 2, 3, 4].map(n => ({ src: `/books/serkebayev/photo-${n}.jpg` }))
|
|
const photos = bookPhotoList(await loadSettings(locale), base).map((p, i) => ({ src: p.src, alt: `${t.book.photo} ${i + 1}` }))
|
|
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}: ${t.book.title}`} 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>
|
|
<PhotoGallery photos={photos} t={t.book} />
|
|
{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>
|
|
}
|