Compare commits
7 Commits
1a21531c17
...
d972b920ca
| Author | SHA1 | Date | |
|---|---|---|---|
| d972b920ca | |||
| 08e2cb0ed5 | |||
| ecc93c4ed2 | |||
| 136ad2ab24 | |||
| 92b48a7e8a | |||
| 7b4de503b5 | |||
| fc2b5a4127 |
@ -16,6 +16,8 @@
|
|||||||
- QLFW-5: отдельные разделы /[locale]/about, /projects, /contacts, /news и /news/[id]; тексты sections в ru/kk/en. News: body/sourceUrl локализованы, imageUrl общий; без перевода заголовка материал скрыт, пустой /news = 404. Контакты без формы по QLFW-11.
|
- QLFW-5: отдельные разделы /[locale]/about, /projects, /contacts, /news и /news/[id]; тексты sections в ru/kk/en. News: body/sourceUrl локализованы, imageUrl общий; без перевода заголовка материал скрыт, пустой /news = 404. Контакты без формы по QLFW-11.
|
||||||
- QLFW-52: люди и партнёры страницы «О фонде» — src/lib/about-model.ts (по языкам, пока пусто); блок виден только при непустом списке.
|
- QLFW-52: люди и партнёры страницы «О фонде» — src/lib/about-model.ts (по языкам, пока пусто); блок виден только при непустом списке.
|
||||||
- QLFW-46: фраза согласия в ContactForm — form.consent (без политики) или form.consentPolicy{Before,Link,After} (со ссылкой, если isLegalPublished). Общую рабочую копию правят параллельные сессии — работать в git worktree (ln -s node_modules для проверок).
|
- QLFW-46: фраза согласия в ContactForm — form.consent (без политики) или form.consentPolicy{Before,Link,After} (со ссылкой, если isLegalPublished). Общую рабочую копию правят параллельные сессии — работать в git worktree (ln -s node_modules для проверок).
|
||||||
|
- QLFW-55: руководство фонда — глобал Payload `foundation` (имена без перевода, роль chair/member; подписи в i18n sections), значения по умолчанию в src/lib/foundation-people.ts; миграция написана вручную (SQL). Общая плашка «перевод на проверке» на kk/en — на всю страницу, не на блоки. В macOS sed -i требует суффикс — правки файлов с [locale] делать через python.
|
||||||
|
- QLFW-44: ссылки магазинов в BookWhere — карта storeUrls; Flip.kz = bookUrl, Marwin = marwinUrl (src/lib/home-model.ts, пусто → просто название); при пустом адресе ссылка не показывается.
|
||||||
|
|
||||||
## Грабли
|
## Грабли
|
||||||
- QLFW-32: страница книги уже была готова (QLFW-8); локальный main может отставать — worktree делать от origin/main после git fetch.
|
- QLFW-32: страница книги уже была готова (QLFW-8); локальный main может отставать — worktree делать от origin/main после git fetch.
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
## Решения
|
||||||
|
- Имена хранятся без перевода; должность совета — выбор «Председатель / Член совета», подписи переводятся в словарях i18n.
|
||||||
|
- Данные заказчика зашиты как значения по умолчанию (`src/lib/foundation-people.ts`), админ-панель их переопределяет — страница не пустая на свежей базе.
|
||||||
|
- Новая миграция `20261117_190000_foundation` — явный SQL (последний json в migrations — юридические тексты, не snapshot).
|
||||||
|
- Дублей нет: блоки руководства не повторяют миссию, цели и направления. Общая плашка «перевод на проверке» на kk/en относится ко всей странице и не менялась (QLFW-52 правит ту же страницу).
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
## Why
|
||||||
|
На странице «О фонде» вместо учредителя, директора и попечительского совета стояли пометки «Нужно уточнить». Заказчик прислал данные.
|
||||||
|
## What Changes
|
||||||
|
- Глобал Payload `foundation` (учредитель, директор, состав совета) — правится в админ-панели.
|
||||||
|
- Страница «О фонде» показывает эти данные; должности переведены на ru/kk/en, имена не меняются.
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
## ADDED Requirements
|
||||||
|
### Requirement: Руководство фонда на странице «О фонде»
|
||||||
|
Страница SHALL показывать учредителя, директора и попечительский совет с должностями без пометок «Нужно уточнить»; данные SHALL редактироваться в админ-панели.
|
||||||
|
|
||||||
|
#### Scenario: Русская страница
|
||||||
|
- **GIVEN** в админ-панели руководство не менялось
|
||||||
|
- **WHEN** посетитель открывает /ru/about
|
||||||
|
- **THEN** видны учредитель, директор и трое членов совета с должностями
|
||||||
|
- **AND** пометок «Нужно уточнить» нет
|
||||||
|
|
||||||
|
#### Scenario: Казахская и английская страницы
|
||||||
|
- **GIVEN** руководство заполнено
|
||||||
|
- **WHEN** посетитель открывает /kk/about или /en/about
|
||||||
|
- **THEN** должности переведены, имена такие же, как на русском
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
- [x] Глобал Foundation и миграция
|
||||||
|
- [x] Данные по умолчанию и переводы должностей
|
||||||
|
- [x] Вывод на странице «О фонде», тесты
|
||||||
4
openspec/changes/qlfw-44-store-links/proposal.md
Normal file
4
openspec/changes/qlfw-44-store-links/proposal.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
## Why
|
||||||
|
Marwin и Flip.kz в «Где купить книгу» были просто словами.
|
||||||
|
## What
|
||||||
|
Flip.kz — ссылка (новая вкладка) на страницу книги на всех языках. Marwin — ссылка на страницу книги (`marwinUrl` в home-model; если пуст — показывается название). Фраза про наличие и стоимость не менялась.
|
||||||
1
openspec/changes/qlfw-44-store-links/tasks.md
Normal file
1
openspec/changes/qlfw-44-store-links/tasks.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
- [x] ссылки, тест
|
||||||
20
openspec/specs/site-sections/spec.md
Normal file
20
openspec/specs/site-sections/spec.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# site-sections Specification
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
TBD - created by archiving change qlfw-55-about-leadership. Update Purpose after archive.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
### Requirement: Руководство фонда на странице «О фонде»
|
||||||
|
Страница SHALL показывать учредителя, директора и попечительский совет с должностями без пометок «Нужно уточнить»; данные SHALL редактироваться в админ-панели.
|
||||||
|
|
||||||
|
#### Scenario: Русская страница
|
||||||
|
- **GIVEN** в админ-панели руководство не менялось
|
||||||
|
- **WHEN** посетитель открывает /ru/about
|
||||||
|
- **THEN** видны учредитель, директор и трое членов совета с должностями
|
||||||
|
- **AND** пометок «Нужно уточнить» нет
|
||||||
|
|
||||||
|
#### Scenario: Казахская и английская страницы
|
||||||
|
- **GIVEN** руководство заполнено
|
||||||
|
- **WHEN** посетитель открывает /kk/about или /en/about
|
||||||
|
- **THEN** должности переведены, имена такие же, как на русском
|
||||||
@ -1,9 +1,10 @@
|
|||||||
import { notFound } from 'next/navigation'
|
import { notFound } from 'next/navigation'
|
||||||
import { getDict, isLocale, locales } from '@/i18n'
|
import { getDict, isLocale, locales } from '@/i18n'
|
||||||
import { loadContent, loadLegal } from '@/lib/content'
|
import { loadContent, loadFoundation, loadLegal } from '@/lib/content'
|
||||||
import { buildHomeModel } from '@/lib/home-model'
|
import { buildHomeModel } from '@/lib/home-model'
|
||||||
import { SectionPage } from '@/components/SectionPage'
|
import { SectionPage } from '@/components/SectionPage'
|
||||||
import { aboutPeople } from '@/lib/about-model'
|
import { aboutPeople } from '@/lib/about-model'
|
||||||
|
import { buildFoundationPeople } from '@/lib/foundation-people'
|
||||||
|
|
||||||
export const dynamic = 'force-dynamic'
|
export const dynamic = 'force-dynamic'
|
||||||
export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
|
export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
|
||||||
@ -19,18 +20,20 @@ export default async function Page({ params }: { params: Promise<{ locale: strin
|
|||||||
const { home, news } = await loadContent(locale)
|
const { home, news } = await loadContent(locale)
|
||||||
const m = buildHomeModel(home, news, t)
|
const m = buildHomeModel(home, news, t)
|
||||||
const data = aboutPeople[locale]
|
const data = aboutPeople[locale]
|
||||||
const people = [
|
const people = buildFoundationPeople(await loadFoundation())
|
||||||
{ label: t.sections.founder, items: data.founder },
|
|
||||||
{ label: t.sections.leadership, items: data.leadership },
|
|
||||||
{ label: t.sections.board, items: data.board },
|
|
||||||
].filter(b => b.items.length > 0)
|
|
||||||
return <SectionPage legal={await loadLegal(locale)} t={t} locale={locale} path="/about" title={t.sections.about} showNews={m.news.length > 0}>
|
return <SectionPage legal={await loadLegal(locale)} t={t} locale={locale} path="/about" title={t.sections.about} showNews={m.news.length > 0}>
|
||||||
<section><h2 className="font-serif text-2xl">{t.mission.title}</h2><p className="mt-4 max-w-3xl text-lg">{m.mission.text}</p></section>
|
<section><h2 className="font-serif text-2xl">{t.mission.title}</h2><p className="mt-4 max-w-3xl text-lg">{m.mission.text}</p></section>
|
||||||
<section className="mt-12"><h2 className="font-serif text-2xl">{t.sections.goals}</h2><p className="mt-4 max-w-3xl">{t.sections.goalText}</p></section>
|
<section className="mt-12"><h2 className="font-serif text-2xl">{t.sections.goals}</h2><p className="mt-4 max-w-3xl">{t.sections.goalText}</p></section>
|
||||||
<section id="directions" className="mt-12 scroll-mt-8"><h2 className="font-serif text-2xl">{t.directions.title}</h2>
|
<section id="directions" className="mt-12 scroll-mt-8"><h2 className="font-serif text-2xl">{t.directions.title}</h2>
|
||||||
<ul className="mt-6 grid gap-6 sm:grid-cols-2">{m.directions.map(d => <li key={d.title} className="border border-line p-6"><h3 className="font-serif text-xl">{d.title}</h3><p className="mt-3">{d.text}</p></li>)}</ul>
|
<ul className="mt-6 grid gap-6 sm:grid-cols-2">{m.directions.map(d => <li key={d.title} className="border border-line p-6"><h3 className="font-serif text-xl">{d.title}</h3><p className="mt-3">{d.text}</p></li>)}</ul>
|
||||||
</section>
|
</section>
|
||||||
{people.length > 0 && <div className="mt-12 grid gap-6 sm:grid-cols-3">{people.map(b => <section key={b.label}><h2 className="mb-4 font-serif text-2xl">{b.label}</h2><ul className="space-y-2">{b.items.map(p => <li key={p.name}><span className="font-medium">{p.name}</span>{p.role ? <span className="block text-sm text-muted">{p.role}</span> : null}</li>)}</ul></section>)}</div>}
|
<div className="mt-12 grid gap-8 sm:grid-cols-3">
|
||||||
|
<section id="founder"><h2 className="mb-4 font-serif text-2xl">{t.sections.founder}</h2><p>{people.founder}</p></section>
|
||||||
|
<section id="leadership"><h2 className="mb-4 font-serif text-2xl">{t.sections.leadership}</h2><p className="text-sm text-graphite">{t.sections.director}</p><p>{people.director}</p></section>
|
||||||
|
<section id="board"><h2 className="mb-4 font-serif text-2xl">{t.sections.board}</h2>
|
||||||
|
<ul className="space-y-3">{people.board.map(b => <li key={b.name}><p className="text-sm text-graphite">{b.role === 'chair' ? t.sections.chair : t.sections.boardMember}</p><p>{b.name}</p></li>)}</ul>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
{data.partners.length > 0 && <section className="mt-12"><h2 className="font-serif text-2xl">{t.sections.partners}</h2><ul className="mt-4 space-y-2">{data.partners.map(p => <li key={p.name}>{p.url ? <a className="underline" href={p.url}>{p.name}</a> : p.name}</li>)}</ul></section>}
|
{data.partners.length > 0 && <section className="mt-12"><h2 className="font-serif text-2xl">{t.sections.partners}</h2><ul className="mt-4 space-y-2">{data.partners.map(p => <li key={p.name}>{p.url ? <a className="underline" href={p.url}>{p.name}</a> : p.name}</li>)}</ul></section>}
|
||||||
</SectionPage>
|
</SectionPage>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import type { Dict } from '@/i18n'
|
import type { Dict } from '@/i18n'
|
||||||
|
import { bookUrl, marwinUrl } from '@/lib/home-model'
|
||||||
|
|
||||||
|
const storeUrls: Record<string, string> = { Marwin: marwinUrl, 'Flip.kz': bookUrl }
|
||||||
|
|
||||||
export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) {
|
export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) {
|
||||||
const buy = t.buy
|
const buy = t.buy
|
||||||
@ -7,16 +10,19 @@ export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) {
|
|||||||
return (
|
return (
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
<h4 className="font-serif text-xl sm:text-2xl">{t.get}</h4>
|
<h4 className="font-serif text-xl sm:text-2xl">{t.get}</h4>
|
||||||
{(
|
<p className="mt-3 text-muted">{buy.intro}</p>
|
||||||
<>
|
<ul className="mt-3 list-disc space-y-1 pl-6 text-muted">
|
||||||
<p className="mt-3 text-muted">{buy.intro}</p>
|
{buy.platforms.map((p) => {
|
||||||
<ul className="mt-3 list-disc space-y-1 pl-6 text-muted">
|
const href = storeUrls[p]
|
||||||
{buy.platforms.map((p) => <li key={p}>{p}</li>)}
|
return (
|
||||||
</ul>
|
<li key={p}>
|
||||||
<p className="mt-3 text-muted">{buy.stores}</p>
|
{href ? <a href={href} target="_blank" rel="noopener noreferrer" className="underline">{p}</a> : p}
|
||||||
<p className="mt-3 text-muted">{buy.note}</p>
|
</li>
|
||||||
</>
|
)
|
||||||
)}
|
})}
|
||||||
|
</ul>
|
||||||
|
<p className="mt-3 text-muted">{buy.stores}</p>
|
||||||
|
<p className="mt-3 text-muted">{buy.note}</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,28 +2,33 @@ import { createElement } from 'react'
|
|||||||
import { renderToStaticMarkup } from 'react-dom/server'
|
import { renderToStaticMarkup } from 'react-dom/server'
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { getDict } from '@/i18n'
|
import { getDict } from '@/i18n'
|
||||||
|
import { bookUrl, marwinUrl } from '@/lib/home-model'
|
||||||
import { BookWhere } from './BookWhere'
|
import { BookWhere } from './BookWhere'
|
||||||
|
|
||||||
const render = (l: 'ru' | 'kk' | 'en') => {
|
const render = (l: 'ru' | 'kk' | 'en') => {
|
||||||
const d = getDict(l)
|
const d = getDict(l)
|
||||||
return renderToStaticMarkup(createElement(BookWhere, { t: d.book, tbc: d.tbc }))
|
return renderToStaticMarkup(createElement(BookWhere, { t: d.book, tbc: d.tbc }))
|
||||||
}
|
}
|
||||||
|
const link = (href: string, name: string) =>
|
||||||
|
`<a href="${href.replace(/&/g, '&')}" target="_blank" rel="noopener noreferrer" class="underline">${name}</a>`
|
||||||
|
|
||||||
describe('Сценарий: где купить книгу', () => {
|
describe('Сценарий: где купить книгу', () => {
|
||||||
it('русский текст целиком, площадки списком без ссылок', () => {
|
it.each(['ru', 'kk', 'en'] as const)('язык %s: Marwin и Flip.kz — ссылки в новой вкладке, без пометок', (l) => {
|
||||||
const html = render('ru')
|
|
||||||
expect(html).toContain('Где купить книгу')
|
|
||||||
expect(html).toContain('можно приобрести онлайн на платформах:')
|
|
||||||
expect(html).toContain('<li>Marwin</li><li>Flip.kz</li>')
|
|
||||||
expect(html).toContain('<p class="mt-3 text-muted">Наличие и стоимость книги уточняйте непосредственно у продавцов.</p>')
|
|
||||||
expect(html).not.toContain('<a')
|
|
||||||
})
|
|
||||||
it.each(['kk', 'en'] as const)('язык %s: те же магазины, без пометок', (l) => {
|
|
||||||
const html = render(l)
|
const html = render(l)
|
||||||
expect(html).toContain('<li>Marwin</li><li>Flip.kz</li>')
|
expect(html).toContain(link(marwinUrl, 'Marwin'))
|
||||||
|
expect(html).toContain(link(bookUrl, 'Flip.kz'))
|
||||||
expect(html).toContain('Эрудит')
|
expect(html).toContain('Эрудит')
|
||||||
expect(html).toContain('Книжный мир')
|
expect(html).toContain('Книжный мир')
|
||||||
expect(html).not.toContain(getDict(l).tbc)
|
expect(html).not.toContain(getDict(l).tbc)
|
||||||
expect(html).not.toContain('<a')
|
})
|
||||||
|
it('русский текст: подпись и фраза про наличие на месте', () => {
|
||||||
|
const html = render('ru')
|
||||||
|
expect(html).toContain('Где купить книгу')
|
||||||
|
expect(html).toContain('Наличие и стоимость книги уточняйте непосредственно у продавцов.')
|
||||||
|
})
|
||||||
|
it('без адреса магазина ссылка не показывается, название остаётся', () => {
|
||||||
|
const d = getDict('ru')
|
||||||
|
const html = renderToStaticMarkup(createElement(BookWhere, { t: { ...d.book, buy: { ...d.book.buy!, platforms: ['Неизвестный'] } } }))
|
||||||
|
expect(html).toContain('<li>Неизвестный</li>')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
21
src/globals/Foundation.ts
Normal file
21
src/globals/Foundation.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import type { GlobalConfig } from 'payload'
|
||||||
|
|
||||||
|
/** Руководство фонда. Имена одинаковы на всех языках, должности переводятся сайтом. Пустое поле — сайт покажет сведения по умолчанию. */
|
||||||
|
export const Foundation: GlobalConfig = {
|
||||||
|
slug: 'foundation',
|
||||||
|
label: 'Руководство фонда',
|
||||||
|
access: { read: () => true },
|
||||||
|
fields: [
|
||||||
|
{ name: 'founder', label: 'Учредитель (ФИО)', type: 'text' },
|
||||||
|
{ name: 'director', label: 'Директор (ФИО)', type: 'text' },
|
||||||
|
{
|
||||||
|
name: 'board',
|
||||||
|
label: 'Попечительский совет',
|
||||||
|
type: 'array',
|
||||||
|
fields: [
|
||||||
|
{ name: 'name', label: 'ФИО', type: 'text', required: true },
|
||||||
|
{ name: 'role', label: 'Должность', type: 'select', required: true, defaultValue: 'member', options: [{ label: 'Председатель', value: 'chair' }, { label: 'Член совета', value: 'member' }] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import type { Dict } from './types'
|
import type { Dict } from './types'
|
||||||
|
|
||||||
export const en: Dict = {
|
export const en: Dict = {
|
||||||
sections: {"about": "About the foundation", "contacts": "Contacts", "partners": "Partners", "goals": "Goals", "goalText": "Collect and organise archives, manuscripts and recordings; publish books and music collections; make the legacy available to a wide audience in digital form; support young musicians and researchers; build ties with cultural organisations abroad.", "founder": "Founder", "leadership": "Leadership", "board": "Board of trustees", "read": "Read", "source": "Source", "review": "Translation awaiting review."},
|
sections: {"about": "About the foundation", "contacts": "Contacts", "partners": "Partners", "goals": "Goals", "goalText": "Collect and organise archives, manuscripts and recordings; publish books and music collections; make the legacy available to a wide audience in digital form; support young musicians and researchers; build ties with cultural organisations abroad.", "founder": "Founder", "leadership": "Leadership", "board": "Board of trustees", "director": "Director", "chair": "Chair", "boardMember": "Member of the Board of Trustees", "read": "Read", "source": "Source", "review": "Translation awaiting review."},
|
||||||
siteName: 'Qazaq Legacy Foundation',
|
siteName: 'Qazaq Legacy Foundation',
|
||||||
metaTitle: 'Qazaq Legacy Foundation — a private foundation for Kazakhstan’s heritage',
|
metaTitle: 'Qazaq Legacy Foundation — a private foundation for Kazakhstan’s heritage',
|
||||||
metaDescription:
|
metaDescription:
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { Dict } from './types'
|
import type { Dict } from './types'
|
||||||
|
|
||||||
export const kk: Dict = {
|
export const kk: Dict = {
|
||||||
sections: {"about": "Қор туралы", "contacts": "Байланыс", "partners": "Серіктестер", "goals": "Мақсаттар", "goalText": "Мұрағаттарды, қолжазбалар мен жазбаларды жинап, жүйелеу; кітаптар мен музыкалық жинақтар шығару; мұраны кең аудиторияға цифрлық түрде ұсыну; жас музыканттар мен зерттеушілерге қолдау көрсету; шетелдік мәдени ұйымдармен байланыс орнату.", "founder": "Құрылтайшы", "leadership": "Басшылық", "board": "Қамқоршылық кеңес", "read": "Оқу", "source": "Дереккөз", "review": "Аударманы тексеру қажет."},
|
sections: {"about": "Қор туралы", "contacts": "Байланыс", "partners": "Серіктестер", "goals": "Мақсаттар", "goalText": "Мұрағаттарды, қолжазбалар мен жазбаларды жинап, жүйелеу; кітаптар мен музыкалық жинақтар шығару; мұраны кең аудиторияға цифрлық түрде ұсыну; жас музыканттар мен зерттеушілерге қолдау көрсету; шетелдік мәдени ұйымдармен байланыс орнату.", "founder": "Құрылтайшы", "leadership": "Басшылық", "board": "Қамқоршылық кеңес", "director": "Директор", "chair": "Төраға", "boardMember": "Қамқоршылық кеңестің мүшесі", "read": "Оқу", "source": "Дереккөз", "review": "Аударманы тексеру қажет."},
|
||||||
siteName: 'Qazaq Legacy Foundation',
|
siteName: 'Qazaq Legacy Foundation',
|
||||||
metaTitle: 'Qazaq Legacy Foundation — Қазақстан мұрасының жеке қоры',
|
metaTitle: 'Qazaq Legacy Foundation — Қазақстан мұрасының жеке қоры',
|
||||||
metaDescription:
|
metaDescription:
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { Dict } from './types'
|
import type { Dict } from './types'
|
||||||
|
|
||||||
export const ru: Dict = {
|
export const ru: Dict = {
|
||||||
sections: {"about": "О фонде", "contacts": "Контакты", "partners": "Партнёры", "goals": "Цели", "goalText": "Собирать и систематизировать архивы, рукописи и записи; издавать книги и музыкальные сборники; открывать наследие широкой аудитории в цифровом виде; помогать молодым музыкантам и исследователям; выстраивать связи с зарубежными культурными организациями.", "founder": "Учредитель", "leadership": "Руководство", "board": "Попечительский совет", "read": "Читать", "source": "Источник", "review": ""},
|
sections: {"about": "О фонде", "contacts": "Контакты", "partners": "Партнёры", "goals": "Цели", "goalText": "Собирать и систематизировать архивы, рукописи и записи; издавать книги и музыкальные сборники; открывать наследие широкой аудитории в цифровом виде; помогать молодым музыкантам и исследователям; выстраивать связи с зарубежными культурными организациями.", "founder": "Учредитель", "leadership": "Руководство", "board": "Попечительский совет", "director": "Директор", "chair": "Председатель", "boardMember": "Член Попечительского совета", "read": "Читать", "source": "Источник", "review": ""},
|
||||||
siteName: 'Qazaq Legacy Foundation',
|
siteName: 'Qazaq Legacy Foundation',
|
||||||
metaTitle: 'Qazaq Legacy Foundation — частный фонд наследия Казахстана',
|
metaTitle: 'Qazaq Legacy Foundation — частный фонд наследия Казахстана',
|
||||||
metaDescription:
|
metaDescription:
|
||||||
|
|||||||
@ -2,7 +2,7 @@ export const locales = ['ru', 'kk', 'en'] as const
|
|||||||
export type Locale = (typeof locales)[number]
|
export type Locale = (typeof locales)[number]
|
||||||
|
|
||||||
export type Dict = {
|
export type Dict = {
|
||||||
sections: { about: string; contacts: string; partners: string; goals: string; goalText: string; founder: string; leadership: string; board: string; read: string; source: string; review: string }
|
sections: { about: string; contacts: string; partners: string; goals: string; goalText: string; founder: string; leadership: string; board: string; director: string; chair: string; boardMember: string; read: string; source: string; review: string }
|
||||||
siteName: string
|
siteName: string
|
||||||
metaTitle: string
|
metaTitle: string
|
||||||
metaDescription: string
|
metaDescription: string
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { visibleNews } from './news-model'
|
|||||||
import type { Locale } from '@/i18n'
|
import type { Locale } from '@/i18n'
|
||||||
import type { CmsHome, CmsNews } from './home-model'
|
import type { CmsHome, CmsNews } from './home-model'
|
||||||
import type { CmsLegal } from './legal-model'
|
import type { CmsLegal } from './legal-model'
|
||||||
|
import type { CmsFoundation } from './foundation-people'
|
||||||
|
|
||||||
/** Читает контент из Payload. Любая ошибка (нет базы, не создана таблица) — пустой контент, страница остаётся рабочей. */
|
/** Читает контент из Payload. Любая ошибка (нет базы, не создана таблица) — пустой контент, страница остаётся рабочей. */
|
||||||
export async function loadContent(locale: Locale): Promise<{ home: CmsHome | null; news: CmsNews[] }> {
|
export async function loadContent(locale: Locale): Promise<{ home: CmsHome | null; news: CmsNews[] }> {
|
||||||
@ -44,3 +45,14 @@ export async function loadNews(locale: Locale): Promise<CmsNews[]> {
|
|||||||
page++
|
page++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Руководство фонда; при ошибке чтения — null, страница покажет данные по умолчанию. */
|
||||||
|
export async function loadFoundation(): Promise<CmsFoundation | null> {
|
||||||
|
try {
|
||||||
|
const payload = await getPayload({ config })
|
||||||
|
return (await payload.findGlobal({ slug: 'foundation' })) as unknown as CmsFoundation
|
||||||
|
} catch (e) {
|
||||||
|
console.error('foundation load failed', e)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
20
src/lib/foundation-people.ts
Normal file
20
src/lib/foundation-people.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
export type BoardRole = 'chair' | 'member'
|
||||||
|
export type CmsFoundation = { founder?: string | null; director?: string | null; board?: { name?: string | null; role?: string | null }[] | null }
|
||||||
|
export type FoundationPeople = { founder: string; director: string; board: { name: string; role: BoardRole }[] }
|
||||||
|
|
||||||
|
/** Данные заказчика (QLFW-55); админ-панель их переопределяет. */
|
||||||
|
export const defaultFoundationPeople: FoundationPeople = {
|
||||||
|
founder: 'Рахимжанова Сандугаш Нурабаевна',
|
||||||
|
director: 'Рахимжанова Сандугаш Нурабаевна',
|
||||||
|
board: [
|
||||||
|
{ name: 'Далабаева Алия Сериковна', role: 'chair' },
|
||||||
|
{ name: 'Байжанов Бекдар Ерланович', role: 'member' },
|
||||||
|
{ name: 'Баймухаметова Алия Албековна', role: 'member' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildFoundationPeople(cms: CmsFoundation | null): FoundationPeople {
|
||||||
|
const d = defaultFoundationPeople
|
||||||
|
const board = (cms?.board ?? []).filter(b => b?.name?.trim()).map(b => ({ name: b.name!.trim(), role: (b.role === 'chair' ? 'chair' : 'member') as BoardRole }))
|
||||||
|
return { founder: cms?.founder?.trim() || d.founder, director: cms?.director?.trim() || d.director, board: board.length ? board : d.board }
|
||||||
|
}
|
||||||
@ -13,19 +13,21 @@ vi.mock('./content', () => ({
|
|||||||
loadContent: vi.fn(async () => ({ home: null, news: [] })),
|
loadContent: vi.fn(async () => ({ home: null, news: [] })),
|
||||||
loadNews: vi.fn(async () => []),
|
loadNews: vi.fn(async () => []),
|
||||||
loadLegal: vi.fn(async () => null),
|
loadLegal: vi.fn(async () => null),
|
||||||
|
loadFoundation: vi.fn(async () => null),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe('Разделы и языки', () => {
|
describe('Разделы и языки', () => {
|
||||||
for (const locale of locales) {
|
for (const locale of locales) {
|
||||||
const params = Promise.resolve({ locale })
|
const params = Promise.resolve({ locale })
|
||||||
it(`Нет сведений о руководстве: блоки и пометки скрыты, цели не повторяют миссию — ${locale}`, async () => {
|
it(`Руководство фонда показано без пометок, партнёры скрыты — ${locale}`, async () => {
|
||||||
const html = renderToStaticMarkup(await About({ params }))
|
const html = renderToStaticMarkup(await About({ params }))
|
||||||
const t = getDict(locale)
|
const t = getDict(locale)
|
||||||
expect(html).not.toContain(t.sections.founder)
|
expect(html).toContain(t.sections.founder)
|
||||||
expect(html).not.toContain(t.sections.leadership)
|
expect(html).toContain(t.sections.board)
|
||||||
expect(html).not.toContain(t.sections.board)
|
|
||||||
expect(html).not.toContain(t.sections.partners)
|
|
||||||
expect(html).not.toContain(t.tbc)
|
expect(html).not.toContain(t.tbc)
|
||||||
|
expect(html).not.toContain(t.sections.partners)
|
||||||
|
for (const n of ['Рахимжанова Сандугаш Нурабаевна', 'Далабаева Алия Сериковна', 'Байжанов Бекдар Ерланович', 'Баймухаметова Алия Албековна']) expect(html).toContain(n)
|
||||||
|
for (const r of [t.sections.director, t.sections.chair, t.sections.boardMember]) expect(html).toContain(r)
|
||||||
expect(html).toContain(t.mission.text)
|
expect(html).toContain(t.mission.text)
|
||||||
expect(html).toContain(t.sections.goalText)
|
expect(html).toContain(t.sections.goalText)
|
||||||
expect(t.mission.text).not.toContain(t.sections.goalText)
|
expect(t.mission.text).not.toContain(t.sections.goalText)
|
||||||
|
|||||||
@ -21,6 +21,8 @@ export type HomeModel = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const foundationEmail = 'qazaqlegacy@gmail.com'
|
export const foundationEmail = 'qazaqlegacy@gmail.com'
|
||||||
|
// Адрес книги на Marwin; если пусто — ссылка не показывается.
|
||||||
|
export const marwinUrl = 'https://www.marwin.kz/product/serkebaeva-i-ermek-serkebaev-i-zhizn-i-molodost-i-schaste-220988'
|
||||||
export const bookUrl = 'https://www.flip.kz/catalog?prod=6364653&utm_source=ig&utm_medium=social&utm_content=link_in_bio'
|
export const bookUrl = 'https://www.flip.kz/catalog?prod=6364653&utm_source=ig&utm_medium=social&utm_content=link_in_bio'
|
||||||
|
|
||||||
const clean = (v?: string | null) => (v && v.trim() ? v.trim() : null)
|
const clean = (v?: string | null) => (v && v.trim() ? v.trim() : null)
|
||||||
|
|||||||
26
src/migrations/20261117_190000_foundation.ts
Normal file
26
src/migrations/20261117_190000_foundation.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { type MigrateUpArgs, type MigrateDownArgs, sql } from '@payloadcms/db-sqlite'
|
||||||
|
|
||||||
|
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
||||||
|
await db.run(sql`CREATE TABLE \`foundation_board\` (
|
||||||
|
\`_order\` integer NOT NULL,
|
||||||
|
\`_parent_id\` integer NOT NULL,
|
||||||
|
\`id\` text PRIMARY KEY NOT NULL,
|
||||||
|
\`name\` text NOT NULL,
|
||||||
|
\`role\` text DEFAULT 'member' NOT NULL,
|
||||||
|
FOREIGN KEY (\`_parent_id\`) REFERENCES \`foundation\`(\`id\`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);`)
|
||||||
|
await db.run(sql`CREATE INDEX \`foundation_board_order_idx\` ON \`foundation_board\` (\`_order\`);`)
|
||||||
|
await db.run(sql`CREATE INDEX \`foundation_board_parent_id_idx\` ON \`foundation_board\` (\`_parent_id\`);`)
|
||||||
|
await db.run(sql`CREATE TABLE \`foundation\` (
|
||||||
|
\`id\` integer PRIMARY KEY NOT NULL,
|
||||||
|
\`founder\` text,
|
||||||
|
\`director\` text,
|
||||||
|
\`updated_at\` text,
|
||||||
|
\`created_at\` text
|
||||||
|
);`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down({ db }: MigrateDownArgs): Promise<void> {
|
||||||
|
await db.run(sql`DROP TABLE \`foundation_board\``)
|
||||||
|
await db.run(sql`DROP TABLE \`foundation\``)
|
||||||
|
}
|
||||||
@ -4,6 +4,8 @@ import * as migration_20261116_103502_init from './20261116_103502_init';
|
|||||||
import * as migration_20261117_045758_legal from './20261117_045758_legal';
|
import * as migration_20261117_045758_legal from './20261117_045758_legal';
|
||||||
import * as migration_20261117_052512_inquiries from './20261117_052512_inquiries';
|
import * as migration_20261117_052512_inquiries from './20261117_052512_inquiries';
|
||||||
|
|
||||||
|
import * as migration_foundation from './20261117_190000_foundation';
|
||||||
|
|
||||||
export const migrations = [
|
export const migrations = [
|
||||||
|
|
||||||
|
|
||||||
@ -24,4 +26,5 @@ export const migrations = [
|
|||||||
},
|
},
|
||||||
{ up: migration_20261117_120000_legal_texts.up, down: migration_20261117_120000_legal_texts.down, name: '20261117_120000_legal_texts' },
|
{ 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' },
|
{ up: migration_news_details.up, down: migration_news_details.down, name: '20261117_170000_news_details' },
|
||||||
|
{ up: migration_foundation.up, down: migration_foundation.down, name: '20261117_190000_foundation' },
|
||||||
];
|
];
|
||||||
|
|||||||
@ -92,10 +92,12 @@ export interface Config {
|
|||||||
globals: {
|
globals: {
|
||||||
home: Home;
|
home: Home;
|
||||||
legal: Legal;
|
legal: Legal;
|
||||||
|
foundation: Foundation;
|
||||||
};
|
};
|
||||||
globalsSelect: {
|
globalsSelect: {
|
||||||
home: HomeSelect<false> | HomeSelect<true>;
|
home: HomeSelect<false> | HomeSelect<true>;
|
||||||
legal: LegalSelect<false> | LegalSelect<true>;
|
legal: LegalSelect<false> | LegalSelect<true>;
|
||||||
|
foundation: FoundationSelect<false> | FoundationSelect<true>;
|
||||||
};
|
};
|
||||||
locale: 'ru' | 'kk' | 'en';
|
locale: 'ru' | 'kk' | 'en';
|
||||||
widgets: {
|
widgets: {
|
||||||
@ -388,14 +390,14 @@ export interface Legal {
|
|||||||
id: number;
|
id: number;
|
||||||
privacy?: {
|
privacy?: {
|
||||||
/**
|
/**
|
||||||
* Только текст из документа фонда. Абзацы разделяйте пустой строкой. Пусто — сайт покажет «Нужно уточнить».
|
* Только текст из документа фонда. Абзацы разделяйте пустой строкой. Без полного текста и даты ссылка на документ скрыта.
|
||||||
*/
|
*/
|
||||||
body?: string | null;
|
body?: string | null;
|
||||||
updated?: string | null;
|
updated?: string | null;
|
||||||
};
|
};
|
||||||
terms?: {
|
terms?: {
|
||||||
/**
|
/**
|
||||||
* Только текст из документа фонда. Абзацы разделяйте пустой строкой. Пусто — сайт покажет «Нужно уточнить».
|
* Только текст из документа фонда. Абзацы разделяйте пустой строкой. Без полного текста и даты ссылка на документ скрыта.
|
||||||
*/
|
*/
|
||||||
body?: string | null;
|
body?: string | null;
|
||||||
updated?: string | null;
|
updated?: string | null;
|
||||||
@ -403,6 +405,24 @@ export interface Legal {
|
|||||||
updatedAt?: string | null;
|
updatedAt?: string | null;
|
||||||
createdAt?: string | null;
|
createdAt?: string | null;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "foundation".
|
||||||
|
*/
|
||||||
|
export interface Foundation {
|
||||||
|
id: number;
|
||||||
|
founder?: string | null;
|
||||||
|
director?: string | null;
|
||||||
|
board?:
|
||||||
|
| {
|
||||||
|
name: string;
|
||||||
|
role: 'chair' | 'member';
|
||||||
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
|
updatedAt?: string | null;
|
||||||
|
createdAt?: string | null;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "home_select".
|
* via the `definition` "home_select".
|
||||||
@ -450,6 +470,24 @@ export interface LegalSelect<T extends boolean = true> {
|
|||||||
createdAt?: T;
|
createdAt?: T;
|
||||||
globalType?: T;
|
globalType?: T;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "foundation_select".
|
||||||
|
*/
|
||||||
|
export interface FoundationSelect<T extends boolean = true> {
|
||||||
|
founder?: T;
|
||||||
|
director?: T;
|
||||||
|
board?:
|
||||||
|
| T
|
||||||
|
| {
|
||||||
|
name?: T;
|
||||||
|
role?: T;
|
||||||
|
id?: T;
|
||||||
|
};
|
||||||
|
updatedAt?: T;
|
||||||
|
createdAt?: T;
|
||||||
|
globalType?: T;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "collections_widget".
|
* via the `definition` "collections_widget".
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { Inquiries } from './collections/Inquiries'
|
|||||||
import { News } from './collections/News'
|
import { News } from './collections/News'
|
||||||
import { Home } from './globals/Home'
|
import { Home } from './globals/Home'
|
||||||
import { Legal } from './globals/Legal'
|
import { Legal } from './globals/Legal'
|
||||||
|
import { Foundation } from './globals/Foundation'
|
||||||
import { migrations } from './migrations'
|
import { migrations } from './migrations'
|
||||||
|
|
||||||
const dirname = path.dirname(fileURLToPath(import.meta.url))
|
const dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
@ -15,7 +16,7 @@ const dirname = path.dirname(fileURLToPath(import.meta.url))
|
|||||||
export default buildConfig({
|
export default buildConfig({
|
||||||
admin: { user: Users.slug },
|
admin: { user: Users.slug },
|
||||||
collections: [Users, News, Inquiries],
|
collections: [Users, News, Inquiries],
|
||||||
globals: [Home, Legal],
|
globals: [Home, Legal, Foundation],
|
||||||
editor: lexicalEditor(),
|
editor: lexicalEditor(),
|
||||||
// mock-секрет только для запуска без настроек; на стенде задаётся PAYLOAD_SECRET.
|
// mock-секрет только для запуска без настроек; на стенде задаётся PAYLOAD_SECRET.
|
||||||
secret: process.env.PAYLOAD_SECRET || 'mock-insecure-secret-replace-me',
|
secret: process.env.PAYLOAD_SECRET || 'mock-insecure-secret-replace-me',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user