From a47524a78bf9cb400c868c7690b796a8f7a23172 Mon Sep 17 00:00:00 2001 From: Peppa Date: Tue, 17 Nov 2026 16:57:30 +0500 Subject: [PATCH 1/6] =?UTF-8?q?QLFW-5:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D1=8B?= =?UTF-8?q?=20=D1=84=D0=BE=D0=BD=D0=B4=D0=B0,=20=D0=BF=D1=80=D0=BE=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=BE=D0=B2=20=D0=B8=20=D0=BA=D0=BE=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/glossary.md | 4 +++ .../qlfw-5-site-sections/.openspec.yaml | 2 ++ .../changes/qlfw-5-site-sections/design.md | 21 +++++++++++++ .../changes/qlfw-5-site-sections/proposal.md | 21 +++++++++++++ .../specs/foundation-sections/spec.md | 31 +++++++++++++++++++ .../changes/qlfw-5-site-sections/tasks.md | 9 ++++++ src/app/(site)/[locale]/about/page.tsx | 29 +++++++++++++++++ src/app/(site)/[locale]/projects/page.tsx | 28 +++++++++++++++++ src/components/Header.tsx | 13 ++++---- src/components/SectionPage.tsx | 15 +++++++++ src/i18n/en.ts | 1 + src/i18n/kk.ts | 1 + src/i18n/ru.ts | 1 + src/i18n/types.ts | 1 + 14 files changed, 170 insertions(+), 7 deletions(-) create mode 100644 openspec/changes/qlfw-5-site-sections/.openspec.yaml create mode 100644 openspec/changes/qlfw-5-site-sections/design.md create mode 100644 openspec/changes/qlfw-5-site-sections/proposal.md create mode 100644 openspec/changes/qlfw-5-site-sections/specs/foundation-sections/spec.md create mode 100644 openspec/changes/qlfw-5-site-sections/tasks.md create mode 100644 src/app/(site)/[locale]/about/page.tsx create mode 100644 src/app/(site)/[locale]/projects/page.tsx create mode 100644 src/components/SectionPage.tsx diff --git a/docs/glossary.md b/docs/glossary.md index b829f0a..1fadc5e 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -61,3 +61,7 @@ | Форма обращения | обращение, форма обращения, Написать нам | тикет, заявка, фидбэк | Посетитель пишет фонду прямо с сайта | | Страница контактов | Контакты / Байланыс / Contacts | контакт-центр | Страница `/…/contacts` с формой и почтой | | Дата действия документа | Дата вступления в силу / Күшіне ену күні / Effective date | дата редакции | Дата, подтверждённая фондом; без неё документ скрыт | +| Разделы фонда | О фонде / Қор туралы / About the foundation; Контакты / Байланыс / Contacts | — | Отдельные страницы сведений и связи | +| Управление фондом | Учредитель / Құрылтайшы / Founder; Руководство / Басшылық / Leadership; Попечительский совет / Қамқоршылық кеңес / Board of trustees | — | Без неподтверждённых имён | +| Задачи фонда | Цели / Мақсаттар / Goals | — | Цели из подтверждённой миссии | +| Материал | Читать / Оқу / Read; Источник / Дереккөз / Source | — | Страница новости и внешняя публикация | diff --git a/openspec/changes/qlfw-5-site-sections/.openspec.yaml b/openspec/changes/qlfw-5-site-sections/.openspec.yaml new file mode 100644 index 0000000..bbe8b39 --- /dev/null +++ b/openspec/changes/qlfw-5-site-sections/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-11-17 diff --git a/openspec/changes/qlfw-5-site-sections/design.md b/openspec/changes/qlfw-5-site-sections/design.md new file mode 100644 index 0000000..122cc84 --- /dev/null +++ b/openspec/changes/qlfw-5-site-sections/design.md @@ -0,0 +1,21 @@ +## Context +В main уже есть локализованные главная, книга и юридические страницы. Header умеет сохранять путь. QLFW-11 заменяет форму прямой почтой и Instagram, SMTP не нужен. Фото и сведения книги получены в QLFW-8; старые declare_needs не отражают это. + +## Goals / Non-Goals +Добавить отдельные разделы без дублирования источников контента. Не менять решения задач книги и контактов. + +## Decisions +- Серверные страницы /[locale]/about, /projects, /contacts, /news и /news/[id]. Общие Header/Footer, словари ru/kk/en, метаданные каждой страницы. +- О фонде: подтверждённая миссия и направления, цели из миссии; учредитель, руководство и совет — явные пометки без вымышленных имён. Партнёры скрыты. +- Каталог с существующей книгой и её фото; новые проекты добавляются отдельными задачами вместе с их страницами. +- Расширить News необязательными локализованными body, imageUrl, sourceUrl; сохранить существующие данные и дату. URL только http(s), fallbackLocale:false; без локализованного заголовка материал скрыт. Список без лимита главной через пагинацию Payload. Нет материалов — /news возвращает 404, ссылки скрыты. Детали без перевода — 404. +- Контакты: видимая почта и Instagram, приглашение к партнёрству, ссылка на политику. Без формы согласно QLFW-11. + +## Risks / Trade-offs +Переводы новых формулировок kk/en требуют проверки. Внешнее фото новости обычный img с lazy loading: не требует разрешать произвольные домены в оптимизаторе Next. + +## Open Questions +Нет. + +## Миграция +Генератор migrate:create остановился: последний JSON юридической миграции содержит тексты, а не снимок Drizzle. Добавлена явная обратимая SQL-миграция трёх nullable text-колонок; проверена на чистой базе после предыдущих миграций. Старые файлы не меняем. diff --git a/openspec/changes/qlfw-5-site-sections/proposal.md b/openspec/changes/qlfw-5-site-sections/proposal.md new file mode 100644 index 0000000..8bc7757 --- /dev/null +++ b/openspec/changes/qlfw-5-site-sections/proposal.md @@ -0,0 +1,21 @@ +QLFW-5 — основные разделы сайта фонда на трёх языках. + +## Why +Посетителю нужны отдельные адреса для сведений о фонде, проектов и контактов. После прерванной сессии план отсутствует; используем уже принятые QLFW-8, QLFW-9 и QLFW-11. + +## What Changes +- Отдельные страницы о фонде, каталога проектов и контактов; навигация и переключатель языков сохраняют страницу. +- Неизвестные сведения о руководстве явно отмечены; партнёры без данных скрыты. +- Новости с датами, полным текстом, фото и ссылкой; пустой раздел скрыт. + +## Capabilities +### New Capabilities +- `foundation-sections`: разделы фонда и локализованная навигация. +### Modified Capabilities +Нет. + +## Impact +Next App Router, словари, существующая коллекция News. Вне scope: платежи, произвольный конструктор проектов, отправка писем (по QLFW-11 используются почта и Instagram), изменение готовой страницы книги. + +## Открытые вопросы +Нет. Неподтверждённые сведения помечаем, перевод kk/en требует проверки владельцем. diff --git a/openspec/changes/qlfw-5-site-sections/specs/foundation-sections/spec.md b/openspec/changes/qlfw-5-site-sections/specs/foundation-sections/spec.md new file mode 100644 index 0000000..bc27dc5 --- /dev/null +++ b/openspec/changes/qlfw-5-site-sections/specs/foundation-sections/spec.md @@ -0,0 +1,31 @@ +## Purpose +Отдельные разделы помогают посетителям, партнёрам и СМИ находить сведения фонда на русском, казахском и английском. + +## ADDED Requirements + +### Requirement: Разделы и языки +Сайт SHALL предоставлять /about, /projects и /contacts на ru, kk, en с общим стилем, метаданными и переключением языка на тот же путь. О фонде SHALL показывать миссию, цели, направления и пометки для неизвестных учредителя, руководства, совета; партнёры без данных скрыты. Каталог SHALL показывать книгу с фото и ссылкой на её страницу. Контакты SHALL показывать почту, Instagram и приглашение к партнёрству согласно QLFW-11. Сайт SHALL оставаться читаемым от 320px и не содержать пожертвований. + +#### Scenario: Переключение языка каталога +- **GIVEN** посетитель открыл /ru/projects +- **WHEN** он выбирает EN +- **THEN** открывается /en/projects с обложкой и ссылкой на английскую страницу книги + +#### Scenario: Нет сведений о руководстве +- **GIVEN** сведения об учредителе и совете не предоставлены +- **WHEN** посетитель открывает /ru/about +- **THEN** рядом с соответствующими заголовками видно «Нужно уточнить» +- **AND** блока партнёров нет + +### Requirement: Материалы новостей +Сайт SHALL показывать опубликованные в News материалы с локализованным заголовком, датой, текстом, необязательным фото и безопасной внешней ссылкой. Список SHALL содержать все материалы текущего языка; отдельная страница SHALL сохраняться при переключении языка, если перевод есть. Пустой раздел SHALL быть скрыт в меню и возвращать 404; отсутствующий перевод материала SHALL возвращать 404 без подстановки другого языка. + +#### Scenario: Материал опубликован +- **GIVEN** в News есть русская новость «Презентация книги» с датой 2026-11-17 и текстом +- **WHEN** посетитель открывает её из /ru/news +- **THEN** видны заголовок, дата и полный текст + +#### Scenario: Нет перевода +- **GIVEN** новость содержит только русский заголовок +- **WHEN** посетитель открывает её адрес на kk +- **THEN** показана страница отсутствующего материала diff --git a/openspec/changes/qlfw-5-site-sections/tasks.md b/openspec/changes/qlfw-5-site-sections/tasks.md new file mode 100644 index 0000000..99b5422 --- /dev/null +++ b/openspec/changes/qlfw-5-site-sections/tasks.md @@ -0,0 +1,9 @@ +## 1. Разделы +- [x] 1.1 Добавить словарь и страницы о фонде, проектов и контактов, обновить меню; проверить все языки и ссылки. +## 2. Новости +- [x] 2.1 Расширить коллекцию и миграцию, добавить список и страницы материалов; тесты отсутствующего перевода, небезопасных ссылок и пустого раздела. +## 3. Проверка +- [ ] 3.1 Проверить экраны на телефоне и компьютере, тексты по словарю, все проверки проекта и openspec validate. + +## Workflow follow-up +- Память, архив, PR и review после зелёных проверок. diff --git a/src/app/(site)/[locale]/about/page.tsx b/src/app/(site)/[locale]/about/page.tsx new file mode 100644 index 0000000..c25de22 --- /dev/null +++ b/src/app/(site)/[locale]/about/page.tsx @@ -0,0 +1,29 @@ +import { notFound } from 'next/navigation' +import { getDict, isLocale, locales } from '@/i18n' +import { loadContent } from '@/lib/content' +import { buildHomeModel } from '@/lib/home-model' +import { SectionPage } from '@/components/SectionPage' +import { Tbc } from '@/components/Tbc' + +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.sections.about} — ${t.siteName}`, description: t.metaDescription, alternates: { languages: Object.fromEntries(locales.map(l => [l, `/${l}/about`])) } } +} +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) + return 0}> +

{t.mission.title}

{m.mission.text}

+

{t.sections.goals}

{t.sections.goalText}

+

{t.directions.title}

+
    {m.directions.map(d =>
  • {d.title}

    {d.text ?? t.tbc}

  • )}
+
+
{[t.sections.founder,t.sections.leadership,t.sections.board].map(label =>

{label}

)}
+
+} diff --git a/src/app/(site)/[locale]/projects/page.tsx b/src/app/(site)/[locale]/projects/page.tsx new file mode 100644 index 0000000..caf5ec5 --- /dev/null +++ b/src/app/(site)/[locale]/projects/page.tsx @@ -0,0 +1,28 @@ +import { notFound } from 'next/navigation' +import { getDict, isLocale, locales } from '@/i18n' +import { loadContent } from '@/lib/content' +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) + return 0}> +
+ {t.book.cover} +

{t.book.author}

{t.book.title}

{t.book.paragraphs.map(text =>

{text}

)}{t.projects.more}
+
+
+} diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 0d80e45..76638ad 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -3,13 +3,12 @@ import { locales, type Dict, type Locale } from '@/i18n' /** `path` — текущая страница без языка ('' — главная): переключатель языка ведёт на ту же страницу, якоря — на главную. */ export function Header({ t, locale, showProjects, showNews, path = '' }: { t: Dict; locale: Locale; showProjects: boolean; showNews: boolean; path?: string }) { - const home = path ? `/${locale}` : '' const links = [ - ['#mission', t.nav.mission, true], - ['#directions', t.nav.directions, true], - ['#projects', t.nav.projects, showProjects], - ['#news', t.nav.news, showNews], - ['#collaboration', t.nav.collaboration, true], + ['/about', t.sections.about, true], + ['/about#directions', t.nav.directions, true], + ['/projects', t.nav.projects, showProjects], + ['/news', t.news.title, showNews], + ['/contacts', t.sections.contacts, true], ] as const return (
@@ -19,7 +18,7 @@ export function Header({ t, locale, showProjects, showNews, path = '' }: { t: Di
diff --git a/src/components/SectionPage.tsx b/src/components/SectionPage.tsx new file mode 100644 index 0000000..6da07ed --- /dev/null +++ b/src/components/SectionPage.tsx @@ -0,0 +1,15 @@ +import { Header } from './Header' +import { Footer } from './Footer' +import type { Dict, Locale } from '@/i18n' + +export function SectionPage({ t, locale, path, title, showNews, children }: { t: Dict; locale: Locale; path: string; title: string; showNews: boolean; children: React.ReactNode }) { + return <> +
+
+

{title}

+ {t.sections.review &&

{t.sections.review}

} + {children} +
+
+ +} diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 9954d4d..882d4b2 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -1,6 +1,7 @@ import type { Dict } from './types' export const en: Dict = { + sections: {"about": "About the foundation", "contacts": "Contacts", "goals": "Goals", "goalText": "Preserve the legacy of outstanding cultural figures and artists, pass it on to new generations, and support cultural and educational initiatives.", "founder": "Founder", "leadership": "Leadership", "board": "Board of trustees", "read": "Read", "source": "Source", "review": "Translation awaiting review."}, siteName: 'Qazaq Legacy Foundation', metaTitle: 'Qazaq Legacy Foundation — a private foundation for Kazakhstan’s heritage', metaDescription: diff --git a/src/i18n/kk.ts b/src/i18n/kk.ts index 241132b..b97e8ed 100644 --- a/src/i18n/kk.ts +++ b/src/i18n/kk.ts @@ -1,6 +1,7 @@ import type { Dict } from './types' export const kk: Dict = { + sections: {"about": "Қор туралы", "contacts": "Байланыс", "goals": "Мақсаттар", "goalText": "Мәдениет пен өнердің көрнекті қайраткерлерінің мұрасын сақтау, оны жаңа ұрпаққа жеткізу және мәдени-ағартушылық бастамаларды қолдау.", "founder": "Құрылтайшы", "leadership": "Басшылық", "board": "Қамқоршылық кеңес", "read": "Оқу", "source": "Дереккөз", "review": "Аударманы тексеру қажет."}, siteName: 'Qazaq Legacy Foundation', metaTitle: 'Qazaq Legacy Foundation — Қазақстан мұрасының жеке қоры', metaDescription: diff --git a/src/i18n/ru.ts b/src/i18n/ru.ts index 01600ef..9f9ed9e 100644 --- a/src/i18n/ru.ts +++ b/src/i18n/ru.ts @@ -1,6 +1,7 @@ import type { Dict } from './types' export const ru: Dict = { + sections: {"about": "О фонде", "contacts": "Контакты", "goals": "Цели", "goalText": "Сохранять наследие выдающихся деятелей культуры и искусства, передавать его новым поколениям и поддерживать культурные и просветительские инициативы.", "founder": "Учредитель", "leadership": "Руководство", "board": "Попечительский совет", "read": "Читать", "source": "Источник", "review": ""}, siteName: 'Qazaq Legacy Foundation', metaTitle: 'Qazaq Legacy Foundation — частный фонд наследия Казахстана', metaDescription: diff --git a/src/i18n/types.ts b/src/i18n/types.ts index 248e95d..b902faf 100644 --- a/src/i18n/types.ts +++ b/src/i18n/types.ts @@ -2,6 +2,7 @@ export const locales = ['ru', 'kk', 'en'] as const export type Locale = (typeof locales)[number] export type Dict = { + sections: { about: string; contacts: string; goals: string; goalText: string; founder: string; leadership: string; board: string; read: string; source: string; review: string } siteName: string metaTitle: string metaDescription: string -- 2.45.2 From 5c6f4f11576078c70e97f45e820b3c69d872a0d8 Mon Sep 17 00:00:00 2001 From: Peppa Date: Tue, 17 Nov 2026 16:57:35 +0500 Subject: [PATCH 2/6] =?UTF-8?q?QLFW-5:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D1=8B=20=D0=BD=D0=BE=D0=B2=D0=BE=D1=81=D1=82=D0=B5=D0=B9=20?= =?UTF-8?q?=D0=B8=20=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(site)/[locale]/news/[id]/page.tsx | 39 +++++++++++++++++++ src/app/(site)/[locale]/news/page.tsx | 30 ++++++++++++++ src/app/(site)/[locale]/page.tsx | 2 +- .../projects/ermek-serkebayev/page.tsx | 6 ++- src/collections/News.ts | 3 ++ src/components/LegalPage.tsx | 7 ++-- src/lib/content.ts | 18 ++++++++- src/lib/home-model.ts | 5 ++- src/lib/news-model.test.ts | 16 ++++++++ src/lib/news-model.ts | 12 ++++++ .../20261117_170000_news_details.ts | 13 +++++++ src/migrations/index.ts | 3 ++ src/payload-types.ts | 6 +++ 13 files changed, 150 insertions(+), 10 deletions(-) create mode 100644 src/app/(site)/[locale]/news/[id]/page.tsx create mode 100644 src/app/(site)/[locale]/news/page.tsx create mode 100644 src/lib/news-model.test.ts create mode 100644 src/lib/news-model.ts create mode 100644 src/migrations/20261117_170000_news_details.ts diff --git a/src/app/(site)/[locale]/news/[id]/page.tsx b/src/app/(site)/[locale]/news/[id]/page.tsx new file mode 100644 index 0000000..1703143 --- /dev/null +++ b/src/app/(site)/[locale]/news/[id]/page.tsx @@ -0,0 +1,39 @@ +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} +
+
+} diff --git a/src/app/(site)/[locale]/news/page.tsx b/src/app/(site)/[locale]/news/page.tsx new file mode 100644 index 0000000..eb5c45b --- /dev/null +++ b/src/app/(site)/[locale]/news/page.tsx @@ -0,0 +1,30 @@ +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' + +export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) { + const { locale } = await params + if (!isLocale(locale)) notFound() + const t = getDict(locale) + return { title: `${t.news.title} — ${t.siteName}`, description: t.metaDescription, alternates: { languages: Object.fromEntries(locales.map(l => [l, `/${l}/news`])) } } +} +export default async function Page({ params }: { params: Promise<{ locale: string }> }) { + const { locale } = await params + if (!isLocale(locale)) notFound() + const t = getDict(locale) + const news = visibleNews(await loadNews(locale)) + if (!news.length) notFound() + const fmt = new Intl.DateTimeFormat(locale, { dateStyle: 'long' }) + return +
    {news.map(n =>
  • + +

    {n.title}

    + {n.summary &&

    {n.summary}

    } +
  • )}
+
+} diff --git a/src/app/(site)/[locale]/page.tsx b/src/app/(site)/[locale]/page.tsx index 9a667cc..a2e9ed9 100644 --- a/src/app/(site)/[locale]/page.tsx +++ b/src/app/(site)/[locale]/page.tsx @@ -105,7 +105,7 @@ export default async function Home({ params }: { params: Promise<{ locale: strin
{n.kind === 'event' ? t.news.event : t.news.news}
-

{n.title}

+

{n.title}

{n.summary &&

{n.summary}

} {n.place &&

{n.place}

}
diff --git a/src/app/(site)/[locale]/projects/ermek-serkebayev/page.tsx b/src/app/(site)/[locale]/projects/ermek-serkebayev/page.tsx index 4eaac08..c39315a 100644 --- a/src/app/(site)/[locale]/projects/ermek-serkebayev/page.tsx +++ b/src/app/(site)/[locale]/projects/ermek-serkebayev/page.tsx @@ -6,6 +6,7 @@ import { notFound } from 'next/navigation' import { Header } from '@/components/Header' import { Footer } from '@/components/Footer' import { getDict, isLocale } from '@/i18n' +import { loadContent } from '@/lib/content' import { bookUrl } from '@/lib/home-model' export const dynamic = 'force-dynamic' @@ -23,9 +24,10 @@ export default async function BookProject({ params }: { params: Promise<{ locale const { locale } = await params if (!isLocale(locale)) notFound() const t = getDict(locale) + const { news } = await loadContent(locale) return <> -
-
+
0} path={path} /> +
{t.projects.title}
{t.book.cover} diff --git a/src/collections/News.ts b/src/collections/News.ts index ecc182c..25a0ba9 100644 --- a/src/collections/News.ts +++ b/src/collections/News.ts @@ -7,6 +7,9 @@ export const News: CollectionConfig = { access: { read: () => true }, fields: [ { name: 'title', label: 'Заголовок', type: 'text', required: true, localized: true }, + { name: 'body', label: 'Полный текст', type: 'textarea', localized: true }, + { name: 'imageUrl', label: 'Адрес фотографии (https)', type: 'text' }, + { name: 'sourceUrl', label: 'Ссылка на публикацию', type: 'text', localized: true }, { name: 'summary', label: 'Краткое описание', type: 'textarea', localized: true }, { name: 'kind', diff --git a/src/components/LegalPage.tsx b/src/components/LegalPage.tsx index b20b12f..80ceaae 100644 --- a/src/components/LegalPage.tsx +++ b/src/components/LegalPage.tsx @@ -5,7 +5,7 @@ import { notFound } from 'next/navigation' import { Footer } from '@/components/Footer' import { Header } from '@/components/Header' import { getDict, isLocale, locales } from '@/i18n' -import { loadLegal } from '@/lib/content' +import { loadContent, loadLegal } from '@/lib/content' import { buildLegalModel, isLegalPublished, type LegalKind } from '@/lib/legal-model' type Props = { params: Promise<{ locale: string }> } @@ -30,13 +30,14 @@ export async function LegalPage({ params, kind }: Props & { kind: LegalKind }) { const t = getDict(locale) const legal = await loadLegal(locale) if (!isLegalPublished(legal?.[kind])) notFound() + const { news } = await loadContent(locale) const m = buildLegalModel(legal, kind, t) const fmt = new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' }) return ( <> -
-
+
0} path={`/${kind}`} /> +
← {t.legal.back}

{m.title}

{m.updated && ( diff --git a/src/lib/content.ts b/src/lib/content.ts index 4e79ee6..04b53fc 100644 --- a/src/lib/content.ts +++ b/src/lib/content.ts @@ -1,6 +1,7 @@ import { cache } from 'react' import config from '@payload-config' import { getPayload } from 'payload' +import { visibleNews } from './news-model' import type { Locale } from '@/i18n' import type { CmsHome, CmsNews } from './home-model' import type { CmsLegal } from './legal-model' @@ -11,9 +12,9 @@ export async function loadContent(locale: Locale): Promise<{ home: CmsHome | nul const payload = await getPayload({ config }) const [home, news] = await Promise.all([ payload.findGlobal({ slug: 'home', locale, fallbackLocale: false }), - payload.find({ collection: 'news', locale, sort: '-date', limit: 3 }), + loadNews(locale), ]) - return { home: home as unknown as CmsHome, news: news.docs as unknown as CmsNews[] } + return { home: home as unknown as CmsHome, news: visibleNews(news).slice(0, 3) } } catch (e) { console.error('content load failed', e) return { home: null, news: [] } @@ -30,3 +31,16 @@ export const loadLegal = cache(async (locale: Locale): Promise return null } }) + +/** Все новости текущего языка; не ограничиваем каталог тремя карточками главной. */ +export async function loadNews(locale: Locale): Promise { + const payload = await getPayload({ config }) + const items: CmsNews[] = [] + let page = 1 + while (true) { + const result = await payload.find({ collection: 'news', locale, fallbackLocale: false, sort: '-date', limit: 100, page }) + items.push(...result.docs as unknown as CmsNews[]) + if (!result.hasNextPage) return items + page++ + } +} diff --git a/src/lib/home-model.ts b/src/lib/home-model.ts index 6a0a74f..9481428 100644 --- a/src/lib/home-model.ts +++ b/src/lib/home-model.ts @@ -1,3 +1,4 @@ +import { visibleNews } from './news-model' import type { Dict } from '@/i18n' export type CmsItem = { title?: string | null; text?: string | null } @@ -8,7 +9,7 @@ export type CmsHome = { collaboration?: string | null contactEmail?: string | null } -export type CmsNews = { id: string | number; title: string; summary?: string | null; kind?: string | null; date: string; place?: string | null } +export type CmsNews = { id: string | number; title: string; summary?: string | null; kind?: string | null; date: string; place?: string | null; body?: string | null; imageUrl?: string | null; sourceUrl?: string | null } export type Card = { title: string; text: string | null; tbc: boolean } export type HomeModel = { @@ -39,7 +40,7 @@ export function buildHomeModel(cms: CmsHome | null, news: CmsNews[], t: Dict): H mission: { text: mission ?? t.mission.text, tbc: false }, directions, projects, - news, + news: visibleNews(news), collaboration: { text: clean(cms?.collaboration) ?? t.collaboration.text, email: clean(cms?.contactEmail) ?? foundationEmail }, } } diff --git a/src/lib/news-model.test.ts b/src/lib/news-model.test.ts new file mode 100644 index 0000000..1988aa1 --- /dev/null +++ b/src/lib/news-model.test.ts @@ -0,0 +1,16 @@ +import { describe, it, expect } from 'vitest' +import { visibleNews, safeWebUrl } from './news-model' + +describe('Материалы новостей', () => { + it('Материал опубликован: сохраняет дату и полный текст', () => { + const item = { id: 1, title: 'Презентация книги', date: '2026-11-17', body: 'Полный текст' } + expect(visibleNews([item])).toEqual([item]) + }) + it('Нет перевода: скрывает материал без заголовка текущего языка', () => { + expect(visibleNews([{ id: 1, title: '', date: '2026-11-17' }])).toEqual([]) + }) + it('Пустой раздел остаётся пустым', () => expect(visibleNews([])).toEqual([])) + it('Повреждённая дата не ломает страницу', () => expect(visibleNews([{ id: 1, title: 'Новость', date: 'bad' }])).toEqual([])) + it.each(['javascript:alert(1)', 'data:text/html,test', '/relative', 'https://user:password@example.org'])('Небезопасная ссылка %s скрыта', value => expect(safeWebUrl(value)).toBeNull()) + it('Источник открывает обычную веб-страницу', () => expect(safeWebUrl('https://example.org/article')).toBe('https://example.org/article')) +}) diff --git a/src/lib/news-model.ts b/src/lib/news-model.ts new file mode 100644 index 0000000..7d20f49 --- /dev/null +++ b/src/lib/news-model.ts @@ -0,0 +1,12 @@ +import type { CmsNews } from './home-model' + +export function safeWebUrl(value?: string | null): string | null { + if (!value?.trim()) return null + try { + const url = new URL(value) + return ['http:', 'https:'].includes(url.protocol) && !url.username && !url.password ? url.href : null + } catch { return null } +} +export function visibleNews(items: CmsNews[]): CmsNews[] { + return items.filter(item => item.title?.trim() && Number.isFinite(Date.parse(item.date))) +} diff --git a/src/migrations/20261117_170000_news_details.ts b/src/migrations/20261117_170000_news_details.ts new file mode 100644 index 0000000..0ca2474 --- /dev/null +++ b/src/migrations/20261117_170000_news_details.ts @@ -0,0 +1,13 @@ +import { type MigrateUpArgs, type MigrateDownArgs, sql } from '@payloadcms/db-sqlite' + +export async function up({ db }: MigrateUpArgs): Promise { + await db.run(sql`ALTER TABLE news ADD COLUMN image_url text`) + await db.run(sql`ALTER TABLE news_locales ADD COLUMN body text`) + await db.run(sql`ALTER TABLE news_locales ADD COLUMN source_url text`) +} + +export async function down({ db }: MigrateDownArgs): Promise { + await db.run(sql`ALTER TABLE news DROP COLUMN image_url`) + await db.run(sql`ALTER TABLE news_locales DROP COLUMN body`) + await db.run(sql`ALTER TABLE news_locales DROP COLUMN source_url`) +} diff --git a/src/migrations/index.ts b/src/migrations/index.ts index 6286fce..075015a 100644 --- a/src/migrations/index.ts +++ b/src/migrations/index.ts @@ -1,3 +1,4 @@ +import * as migration_news_details from './20261117_170000_news_details'; import * as migration_20261117_120000_legal_texts from './20261117_120000_legal_texts'; import * as migration_20261116_103502_init from './20261116_103502_init'; import * as migration_20261117_045758_legal from './20261117_045758_legal'; @@ -5,6 +6,7 @@ import * as migration_20261117_052512_inquiries from './20261117_052512_inquirie export const migrations = [ + { up: migration_20261116_103502_init.up, down: migration_20261116_103502_init.down, @@ -21,4 +23,5 @@ export const migrations = [ name: '20261117_052512_inquiries' }, { up: migration_20261117_120000_legal_texts.up, down: migration_20261117_120000_legal_texts.down, name: '20261117_120000_legal_texts' }, + { up: migration_news_details.up, down: migration_news_details.down, name: '20261117_170000_news_details' }, ]; diff --git a/src/payload-types.ts b/src/payload-types.ts index 2db0121..d28d48f 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -158,6 +158,9 @@ export interface User { export interface News { id: number; title: string; + body?: string | null; + imageUrl?: string | null; + sourceUrl?: string | null; summary?: string | null; kind?: ('news' | 'event') | null; date: string; @@ -287,6 +290,9 @@ export interface UsersSelect { */ export interface NewsSelect { title?: T; + body?: T; + imageUrl?: T; + sourceUrl?: T; summary?: T; kind?: T; date?: T; -- 2.45.2 From d724bd7d1459a7d4b1ecd5814cd8d469a3044d28 Mon Sep 17 00:00:00 2001 From: Peppa Date: Tue, 17 Nov 2026 17:00:22 +0500 Subject: [PATCH 3/6] =?UTF-8?q?QLFW-5:=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=B8=D1=82=D1=8C=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8B=20=D0=B8=20=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=82=D1=80=D0=B5=D0=B1=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .peppa/memory.md | 2 + .../.openspec.yaml | 0 .../design.md | 0 .../proposal.md | 0 .../specs/foundation-sections/spec.md | 0 .../2026-11-17-qlfw-5-site-sections}/tasks.md | 2 +- .../verification.md | 11 ++++ openspec/specs/foundation-sections/spec.md | 33 ++++++++++ src/lib/book-project.test.ts | 4 +- src/lib/foundation-sections.test.ts | 62 +++++++++++++++++++ 10 files changed, 112 insertions(+), 2 deletions(-) rename openspec/changes/{qlfw-5-site-sections => archive/2026-11-17-qlfw-5-site-sections}/.openspec.yaml (100%) rename openspec/changes/{qlfw-5-site-sections => archive/2026-11-17-qlfw-5-site-sections}/design.md (100%) rename openspec/changes/{qlfw-5-site-sections => archive/2026-11-17-qlfw-5-site-sections}/proposal.md (100%) rename openspec/changes/{qlfw-5-site-sections => archive/2026-11-17-qlfw-5-site-sections}/specs/foundation-sections/spec.md (100%) rename openspec/changes/{qlfw-5-site-sections => archive/2026-11-17-qlfw-5-site-sections}/tasks.md (92%) create mode 100644 openspec/changes/archive/2026-11-17-qlfw-5-site-sections/verification.md create mode 100644 openspec/specs/foundation-sections/spec.md create mode 100644 src/lib/foundation-sections.test.ts diff --git a/.peppa/memory.md b/.peppa/memory.md index 0014b43..27a60cd 100644 --- a/.peppa/memory.md +++ b/.peppa/memory.md @@ -13,6 +13,7 @@ - QLFW-9: базовые тексты главной и книги — src/i18n/{ru,kk,en}.ts; Payload сохраняет приоритет, fallbackLocale отключён. Почта и URL Flip — src/lib/home-model.ts. - QLFW-11: по выбору PM связь — видимая почта и Instagram https://www.instagram.com/serkebayev_book/; без формы показываем обычную ссылку на политику, PrivacyNote оставляем только для форм. SMTP не требуется. +- QLFW-5: отдельные разделы /[locale]/about, /projects, /contacts, /news и /news/[id]; тексты sections в ru/kk/en. News: body/sourceUrl локализованы, imageUrl общий; без перевода заголовка материал скрыт, пустой /news = 404. Контакты без формы по QLFW-11. ## Грабли - QLFW-32: страница книги уже была готова (QLFW-8); локальный main может отставать — worktree делать от origin/main после git fetch. @@ -28,3 +29,4 @@ - QLFW-31: isLegalPublished проверяет текст текущего языка без пометок и валидную updated (дату вступления в силу); неполный документ скрыт, прямой адрес 404. loadLegal кэшируется только в рамках запроса. - QLFW-18 — дубль QLFW-31: ссылки (подвал, согласие) и страницы политики/условий скрыты без полного текста; в Header юр. ссылок нет. Ветка стоит поверх task/qlfw-31. +- payload migrate:create после 20261117_120000_legal_texts падает: этот .json — юридические тексты, не snapshot Drizzle. Для news_details добавлена явная обратимая SQL-миграция; перед генерацией следующих миграций учитывайте неподходящий последний JSON. diff --git a/openspec/changes/qlfw-5-site-sections/.openspec.yaml b/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/.openspec.yaml similarity index 100% rename from openspec/changes/qlfw-5-site-sections/.openspec.yaml rename to openspec/changes/archive/2026-11-17-qlfw-5-site-sections/.openspec.yaml diff --git a/openspec/changes/qlfw-5-site-sections/design.md b/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/design.md similarity index 100% rename from openspec/changes/qlfw-5-site-sections/design.md rename to openspec/changes/archive/2026-11-17-qlfw-5-site-sections/design.md diff --git a/openspec/changes/qlfw-5-site-sections/proposal.md b/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/proposal.md similarity index 100% rename from openspec/changes/qlfw-5-site-sections/proposal.md rename to openspec/changes/archive/2026-11-17-qlfw-5-site-sections/proposal.md diff --git a/openspec/changes/qlfw-5-site-sections/specs/foundation-sections/spec.md b/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/specs/foundation-sections/spec.md similarity index 100% rename from openspec/changes/qlfw-5-site-sections/specs/foundation-sections/spec.md rename to openspec/changes/archive/2026-11-17-qlfw-5-site-sections/specs/foundation-sections/spec.md diff --git a/openspec/changes/qlfw-5-site-sections/tasks.md b/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/tasks.md similarity index 92% rename from openspec/changes/qlfw-5-site-sections/tasks.md rename to openspec/changes/archive/2026-11-17-qlfw-5-site-sections/tasks.md index 99b5422..4e63b9f 100644 --- a/openspec/changes/qlfw-5-site-sections/tasks.md +++ b/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/tasks.md @@ -3,7 +3,7 @@ ## 2. Новости - [x] 2.1 Расширить коллекцию и миграцию, добавить список и страницы материалов; тесты отсутствующего перевода, небезопасных ссылок и пустого раздела. ## 3. Проверка -- [ ] 3.1 Проверить экраны на телефоне и компьютере, тексты по словарю, все проверки проекта и openspec validate. +- [x] 3.1 Проверить экраны на телефоне и компьютере, тексты по словарю, все проверки проекта и openspec validate. ## Workflow follow-up - Память, архив, PR и review после зелёных проверок. diff --git a/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/verification.md b/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/verification.md new file mode 100644 index 0000000..b5d548d --- /dev/null +++ b/openspec/changes/archive/2026-11-17-qlfw-5-site-sections/verification.md @@ -0,0 +1,11 @@ +# Проверка QLFW-5 + +- Chromium: /about, /projects, /contacts на ru/kk/en при 320/375/768/1440px — 36 сочетаний; HTTP 200, без горизонтальной прокрутки и перекрытия заголовка меню. Переключатель сохраняет путь. Скриншоты и полные видимые тексты выгружены в /tmp/qlfw5-*. Новые видимые формулировки сверены с docs/glossary.md; обращение на «вы», тексты из словарей. +- Новости: без данных /news возвращает 404 на всех языках. Временный mock-материал в локальной БД на ru/en: список, переход на страницу, дата, два абзаца, фото, ссылка на источник. На kk без перевода — 404. Тестовые данные не коммитятся и не публикуются. +- Миграция: предыдущие миграции применены к чистой БД, затем новая SQL-миграция успешно добавила три nullable поля. +- Автотесты: 57 тестов (7 файлов), в том числе отдельные разделы и страницы новостей. Тест страницы книги использует mock loadContent для изоляции от CMS. +- lint: 0 ошибок, 10 существующих предупреждений в конфигах и старых миграциях; typecheck проходит. +- Build запускается через .gitea/peppa-check.sh с DATABASE_URI на изолированную мигрированную БД. В существующей локальной dev-базе Payload требует интерактивного подтверждения миграций; эту базу не меняли. + +## Сведения, ожидающие владельца +Учредитель, руководство и совет — явные пометки «Нужно уточнить». Партнёры скрыты. Переводы новых текстов kk/en помечены как требующие проверки. Книга использует уже полученные в QLFW-8 материалы; контакты — почта и Instagram по QLFW-11, без формы и SMTP. Новостей от фонда пока нет, раздел остаётся скрыт до публикации. diff --git a/openspec/specs/foundation-sections/spec.md b/openspec/specs/foundation-sections/spec.md new file mode 100644 index 0000000..220c33e --- /dev/null +++ b/openspec/specs/foundation-sections/spec.md @@ -0,0 +1,33 @@ +# foundation-sections Specification + +## Purpose +Отдельные разделы помогают посетителям, партнёрам и СМИ находить сведения фонда на русском, казахском и английском. + +## Requirements + +### Requirement: Разделы и языки +Сайт SHALL предоставлять /about, /projects и /contacts на ru, kk, en с общим стилем, метаданными и переключением языка на тот же путь. О фонде SHALL показывать миссию, цели, направления и пометки для неизвестных учредителя, руководства, совета; партнёры без данных скрыты. Каталог SHALL показывать книгу с фото и ссылкой на её страницу. Контакты SHALL показывать почту, Instagram и приглашение к партнёрству согласно QLFW-11. Сайт SHALL оставаться читаемым от 320px и не содержать пожертвований. + +#### Scenario: Переключение языка каталога +- **GIVEN** посетитель открыл /ru/projects +- **WHEN** он выбирает EN +- **THEN** открывается /en/projects с обложкой и ссылкой на английскую страницу книги + +#### Scenario: Нет сведений о руководстве +- **GIVEN** сведения об учредителе и совете не предоставлены +- **WHEN** посетитель открывает /ru/about +- **THEN** рядом с соответствующими заголовками видно «Нужно уточнить» +- **AND** блока партнёров нет + +### Requirement: Материалы новостей +Сайт SHALL показывать опубликованные в News материалы с локализованным заголовком, датой, текстом, необязательным фото и безопасной внешней ссылкой. Список SHALL содержать все материалы текущего языка; отдельная страница SHALL сохраняться при переключении языка, если перевод есть. Пустой раздел SHALL быть скрыт в меню и возвращать 404; отсутствующий перевод материала SHALL возвращать 404 без подстановки другого языка. + +#### Scenario: Материал опубликован +- **GIVEN** в News есть русская новость «Презентация книги» с датой 2026-11-17 и текстом +- **WHEN** посетитель открывает её из /ru/news +- **THEN** видны заголовок, дата и полный текст + +#### Scenario: Нет перевода +- **GIVEN** новость содержит только русский заголовок +- **WHEN** посетитель открывает её адрес на kk +- **THEN** показана страница отсутствующего материала diff --git a/src/lib/book-project.test.ts b/src/lib/book-project.test.ts index 0eab4b9..e352d6e 100644 --- a/src/lib/book-project.test.ts +++ b/src/lib/book-project.test.ts @@ -1,10 +1,12 @@ -vi.mock('./content', () => ({ loadLegal: vi.fn().mockResolvedValue(null) })) +vi.mock('./content', () => ({ loadLegal: vi.fn().mockResolvedValue(null), loadContent: vi.fn(async () => ({ home: null, news: [] })) })) import { describe, expect, it, vi } from 'vitest' import { renderToStaticMarkup } from 'react-dom/server' import BookProject from '../app/(site)/[locale]/projects/ermek-serkebayev/page' import { getDict, locales } from '../i18n' import { bookUrl } from './home-model' +vi.mock('./content', () => ({ loadContent: vi.fn(async () => ({ home: null, news: [] })) })) + describe('Подтверждённая страница книги', () => { for (const locale of locales) { it(`Показывает сведения и сохраняет страницу при смене языка: ${locale}`, async () => { diff --git a/src/lib/foundation-sections.test.ts b/src/lib/foundation-sections.test.ts new file mode 100644 index 0000000..5bff2f7 --- /dev/null +++ b/src/lib/foundation-sections.test.ts @@ -0,0 +1,62 @@ +import { describe, it, expect, vi } from 'vitest' +import { renderToStaticMarkup } from 'react-dom/server' +import About from '../app/(site)/[locale]/about/page' +import Projects from '../app/(site)/[locale]/projects/page' +import Contacts from '../app/(site)/[locale]/contacts/page' +import News from '../app/(site)/[locale]/news/page' +import NewsItem from '../app/(site)/[locale]/news/[id]/page' +import { getDict, locales } from '../i18n' +import { loadNews } from './content' + +vi.mock('./content', () => ({ + loadContent: vi.fn(async () => ({ home: null, news: [] })), + loadNews: vi.fn(async () => []), +})) + +describe('Разделы и языки', () => { + for (const locale of locales) { + const params = Promise.resolve({ locale }) + it(`Нет сведений о руководстве: явные пометки, партнёры скрыты — ${locale}`, async () => { + const html = renderToStaticMarkup(await About({ params })) + const t = getDict(locale) + expect(html).toContain(t.sections.founder) + expect(html).toContain(t.sections.board) + expect(html).toContain(t.tbc) + expect(html).toContain(t.mission.text) + expect(html).not.toContain('partners') + }) + it(`Переключение языка каталога сохраняет путь — ${locale}`, async () => { + const html = renderToStaticMarkup(await Projects({ params })) + for (const language of locales) expect(html).toContain(`/${language}/projects`) + expect(html).toContain(`/${locale}/projects/ermek-serkebayev`) + expect(html).toContain('cover.jpg') + }) + it(`Контакты: почта и Instagram по решению QLFW-11 — ${locale}`, async () => { + const html = renderToStaticMarkup(await Contacts({ params })) + expect(html).toContain('mailto:qazaqlegacy@gmail.com') + expect(html).toContain('https://www.instagram.com/serkebayev_book/') + expect(html).toContain(`/${locale}/privacy`) + expect(html).not.toContain(' { + it('Пустой раздел возвращает отсутствующую страницу', async () => { + vi.mocked(loadNews).mockResolvedValueOnce([]) + await expect(News({ params: Promise.resolve({ locale: 'ru' }) })).rejects.toThrow('NEXT_HTTP_ERROR_FALLBACK;404') + }) + it('Материал опубликован: текст, дата и источник', async () => { + vi.mocked(loadNews).mockResolvedValueOnce([{ id: 1, title: 'Презентация книги', date: '2026-11-17', body: 'Первый абзац\n\nВторой абзац', sourceUrl: 'https://example.org/mock-source' }]) + const html = renderToStaticMarkup(await NewsItem({ params: Promise.resolve({ locale: 'ru', id: '1' }) })) + expect(html).toContain('Презентация книги') + expect(html).toContain('Первый абзац') + expect(html).toContain('Второй абзац') + expect(html).toContain('https://example.org/mock-source') + expect(html).toContain('2026-11-17') + }) + it('Нет перевода материала: 404', async () => { + vi.mocked(loadNews).mockResolvedValueOnce([{ id: 1, title: '', date: '2026-11-17' }]) + await expect(NewsItem({ params: Promise.resolve({ locale: 'kk', id: '1' }) })).rejects.toThrow('NEXT_HTTP_ERROR_FALLBACK;404') + }) +}) -- 2.45.2 From ae664e3bb67ef1061e411c5561e91f4ee96d6419 Mon Sep 17 00:00:00 2001 From: Peppa Date: Tue, 17 Nov 2026 17:41:00 +0500 Subject: [PATCH 4/6] =?UTF-8?q?QLFW-5:=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D0=BA=D1=82=D1=8B=20=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=B1=D1=80=D0=B0=D1=89=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?,=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20=D0=BD=D0=B0=20Insta?= =?UTF-8?q?gram,=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- src/app/(site)/[locale]/contacts/page.tsx | 7 +++++-- src/lib/foundation-sections.test.ts | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/(site)/[locale]/contacts/page.tsx b/src/app/(site)/[locale]/contacts/page.tsx index 3dcf800..e8c09fa 100644 --- a/src/app/(site)/[locale]/contacts/page.tsx +++ b/src/app/(site)/[locale]/contacts/page.tsx @@ -30,12 +30,12 @@ export default async function ContactsPage({ params }: Props) { const { locale } = await params if (!isLocale(locale)) notFound() const t = getDict(locale) - const { home } = await loadContent(locale) + const { home, news } = await loadContent(locale) const legal = await loadLegal(locale) const email = home?.contactEmail?.trim() || FALLBACK_EMAIL return ( <> -
+
0} path="/contacts" />
← {t.legal.back}

{t.contacts.title}

@@ -44,6 +44,9 @@ export default async function ContactsPage({ params }: Props) {

{t.contacts.emailLabel}: {email}

+

+ {t.collaboration.instagram} +

diff --git a/src/lib/foundation-sections.test.ts b/src/lib/foundation-sections.test.ts index 5bff2f7..0fadb4c 100644 --- a/src/lib/foundation-sections.test.ts +++ b/src/lib/foundation-sections.test.ts @@ -8,6 +8,7 @@ import NewsItem from '../app/(site)/[locale]/news/[id]/page' import { getDict, locales } from '../i18n' import { loadNews } from './content' +vi.mock('@/app/actions/inquiry', () => ({ submitInquiry: vi.fn() })) vi.mock('./content', () => ({ loadContent: vi.fn(async () => ({ home: null, news: [] })), loadNews: vi.fn(async () => []), @@ -36,7 +37,7 @@ describe('Разделы и языки', () => { expect(html).toContain('mailto:qazaqlegacy@gmail.com') expect(html).toContain('https://www.instagram.com/serkebayev_book/') expect(html).toContain(`/${locale}/privacy`) - expect(html).not.toContain(' Date: Tue, 17 Nov 2026 18:23:07 +0500 Subject: [PATCH 5/6] =?UTF-8?q?QLFW-5:=20=D0=BF=D0=BE=D0=B4=D0=B2=D0=B0?= =?UTF-8?q?=D0=BB=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D0=BE=D0=B2=20?= =?UTF-8?q?=D1=83=D1=87=D0=B8=D1=82=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=BE=D1=82=D1=83=20=D1=8E=D1=80=D0=B8=D0=B4?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D1=85=20=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B2=20(QLFW-31)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- src/app/(site)/[locale]/about/page.tsx | 4 ++-- src/app/(site)/[locale]/news/[id]/page.tsx | 4 ++-- src/app/(site)/[locale]/news/page.tsx | 4 ++-- src/app/(site)/[locale]/projects/page.tsx | 4 ++-- src/components/SectionPage.tsx | 5 +++-- src/lib/book-project.test.ts | 1 - src/lib/foundation-sections.test.ts | 1 + 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/app/(site)/[locale]/about/page.tsx b/src/app/(site)/[locale]/about/page.tsx index c25de22..33e57a7 100644 --- a/src/app/(site)/[locale]/about/page.tsx +++ b/src/app/(site)/[locale]/about/page.tsx @@ -1,6 +1,6 @@ import { notFound } from 'next/navigation' import { getDict, isLocale, locales } from '@/i18n' -import { loadContent } from '@/lib/content' +import { loadContent, loadLegal } from '@/lib/content' import { buildHomeModel } from '@/lib/home-model' import { SectionPage } from '@/components/SectionPage' import { Tbc } from '@/components/Tbc' @@ -18,7 +18,7 @@ export default async function Page({ params }: { params: Promise<{ locale: strin const t = getDict(locale) const { home, news } = await loadContent(locale) const m = buildHomeModel(home, news, t) - return 0}> + return 0}>

{t.mission.title}

{m.mission.text}

{t.sections.goals}

{t.sections.goalText}

{t.directions.title}

diff --git a/src/app/(site)/[locale]/news/[id]/page.tsx b/src/app/(site)/[locale]/news/[id]/page.tsx index 1703143..2ba52ad 100644 --- a/src/app/(site)/[locale]/news/[id]/page.tsx +++ b/src/app/(site)/[locale]/news/[id]/page.tsx @@ -1,7 +1,7 @@ import Link from 'next/link' import { notFound } from 'next/navigation' import { getDict, isLocale, locales } from '@/i18n' -import { loadNews } from '@/lib/content' +import { loadNews, loadLegal } from '@/lib/content' import { visibleNews } from '@/lib/news-model' import { SectionPage } from '@/components/SectionPage' @@ -26,7 +26,7 @@ export default async function Page({ params }: { params: Promise<{ locale: strin if (!n) notFound() const image = safeWebUrl(n.imageUrl) const source = safeWebUrl(n.sourceUrl) - return + return
{n.place &&

{n.place}

} diff --git a/src/app/(site)/[locale]/news/page.tsx b/src/app/(site)/[locale]/news/page.tsx index eb5c45b..c98d5ee 100644 --- a/src/app/(site)/[locale]/news/page.tsx +++ b/src/app/(site)/[locale]/news/page.tsx @@ -1,7 +1,7 @@ import Link from 'next/link' import { notFound } from 'next/navigation' import { getDict, isLocale, locales } from '@/i18n' -import { loadNews } from '@/lib/content' +import { loadNews, loadLegal } from '@/lib/content' import { visibleNews } from '@/lib/news-model' import { SectionPage } from '@/components/SectionPage' @@ -20,7 +20,7 @@ export default async function Page({ params }: { params: Promise<{ locale: strin const news = visibleNews(await loadNews(locale)) if (!news.length) notFound() const fmt = new Intl.DateTimeFormat(locale, { dateStyle: 'long' }) - return + return
    {news.map(n =>
  • {n.title}

    diff --git a/src/app/(site)/[locale]/projects/page.tsx b/src/app/(site)/[locale]/projects/page.tsx index caf5ec5..f84a0f8 100644 --- a/src/app/(site)/[locale]/projects/page.tsx +++ b/src/app/(site)/[locale]/projects/page.tsx @@ -1,6 +1,6 @@ import { notFound } from 'next/navigation' import { getDict, isLocale, locales } from '@/i18n' -import { loadContent } from '@/lib/content' +import { loadContent, loadLegal } from '@/lib/content' import { buildHomeModel } from '@/lib/home-model' import { SectionPage } from '@/components/SectionPage' import Image from 'next/image' @@ -19,7 +19,7 @@ export default async function Page({ params }: { params: Promise<{ locale: strin const t = getDict(locale) const { home, news } = await loadContent(locale) const m = buildHomeModel(home, news, t) - return 0}> + return 0}>
    {t.book.cover}

    {t.book.author}

    {t.book.title}

    {t.book.paragraphs.map(text =>

    {text}

    )}{t.projects.more}
    diff --git a/src/components/SectionPage.tsx b/src/components/SectionPage.tsx index 6da07ed..5ee926f 100644 --- a/src/components/SectionPage.tsx +++ b/src/components/SectionPage.tsx @@ -1,8 +1,9 @@ import { Header } from './Header' import { Footer } from './Footer' +import type { CmsLegal } from '@/lib/legal-model' import type { Dict, Locale } from '@/i18n' -export function SectionPage({ t, locale, path, title, showNews, children }: { t: Dict; locale: Locale; path: string; title: string; showNews: boolean; children: React.ReactNode }) { +export function SectionPage({ t, locale, path, title, showNews, legal, children }: { t: Dict; locale: Locale; path: string; title: string; showNews: boolean; legal: CmsLegal | null; children: React.ReactNode }) { return <>
    @@ -10,6 +11,6 @@ export function SectionPage({ t, locale, path, title, showNews, children }: { t: {t.sections.review &&

    {t.sections.review}

    } {children}
    -