import { loadLegal } from '@/lib/content'
import { isLegalPublished } from '@/lib/legal-model'
import Image from 'next/image'
import { notFound } from 'next/navigation'
import { BookWhere } from '@/components/BookWhere'
import { ContactForm } from '@/components/ContactForm'
import { Footer } from '@/components/Footer'
import { Header } from '@/components/Header'
import Link from 'next/link'
import { getDict, isLocale } from '@/i18n'
import { loadContent, loadProjects, loadSettings } from '@/lib/content'
import { buildContacts, mediaOf, visibleProjects } from '@/lib/site-model'
import { buildHomeModel, type Card } from '@/lib/home-model'
import { FALLBACK_EMAIL } from '@/lib/inquiry'
export const dynamic = 'force-dynamic'
function Cards({ items }: { items: Card[] }) {
return (
{items.map((c) => (
-
{c.title}
{c.text && {c.text}
}
))}
)
}
const Section = ({ id, title, children }: { id: string; title: string; children: React.ReactNode }) => (
)
export default async function Home({ 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 contacts = buildContacts(await loadSettings(locale), home?.contactEmail)
const email = contacts.email ?? m.collaboration.email ?? FALLBACK_EMAIL
const legal = await loadLegal(locale)
const fmt = new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' })
return (
<>
0} />
{t.book.author}
{t.book.title}
{t.book.paragraphs.map((text) =>
{text}
)}
{t.projects.more}
{projects.length > 0 && (
{projects.map((p) => {
const cover = mediaOf(p.cover)
return (
-
{/* eslint-disable-next-line @next/next/no-img-element -- загруженные сотрудниками фото отдаёт Payload */}
{cover &&
}
{p.title}
{p.summary && {p.summary}
}
{t.projects.more}
)
})}
)}
{m.projects.length > 0 &&
}
{m.news.length > 0 && (
{m.news.map((n) => (
-
{n.kind === 'event' ? t.news.event : t.news.news}
{n.title}
{n.summary &&
{n.summary}
}
{n.place &&
{n.place}
}
))}
)}
>
)
}