Compare commits
6 Commits
1a21531c17
...
8cef63c8b6
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cef63c8b6 | |||
| 66b180ebca | |||
| c372aba83d | |||
| 88d9b1fc6a | |||
| 9b2e888b84 | |||
| 3226ce7e4d |
@ -15,6 +15,7 @@
|
||||
- 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-52: люди и партнёры страницы «О фонде» — src/lib/about-model.ts (по языкам, пока пусто); блок виден только при непустом списке.
|
||||
- QLFW-44: ссылки магазинов в BookWhere — карта storeUrls; Flip.kz = bookUrl, Marwin = marwinUrl (src/lib/home-model.ts, пусто → просто название); при пустом адресе ссылка не показывается.
|
||||
|
||||
## Грабли
|
||||
- QLFW-32: страница книги уже была готова (QLFW-8); локальный main может отставать — worktree делать от origin/main после git fetch.
|
||||
|
||||
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] ссылки, тест
|
||||
@ -1,5 +1,8 @@
|
||||
import React from 'react'
|
||||
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 }) {
|
||||
const buy = t.buy
|
||||
@ -7,16 +10,19 @@ export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) {
|
||||
return (
|
||||
<div className="mt-8">
|
||||
<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">
|
||||
{buy.platforms.map((p) => <li key={p}>{p}</li>)}
|
||||
</ul>
|
||||
<p className="mt-3 text-muted">{buy.stores}</p>
|
||||
<p className="mt-3 text-muted">{buy.note}</p>
|
||||
</>
|
||||
)}
|
||||
<p className="mt-3 text-muted">{buy.intro}</p>
|
||||
<ul className="mt-3 list-disc space-y-1 pl-6 text-muted">
|
||||
{buy.platforms.map((p) => {
|
||||
const href = storeUrls[p]
|
||||
return (
|
||||
<li key={p}>
|
||||
{href ? <a href={href} target="_blank" rel="noopener noreferrer" className="underline">{p}</a> : p}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
<p className="mt-3 text-muted">{buy.stores}</p>
|
||||
<p className="mt-3 text-muted">{buy.note}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -2,28 +2,33 @@ import { createElement } from 'react'
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { getDict } from '@/i18n'
|
||||
import { bookUrl, marwinUrl } from '@/lib/home-model'
|
||||
import { BookWhere } from './BookWhere'
|
||||
|
||||
const render = (l: 'ru' | 'kk' | 'en') => {
|
||||
const d = getDict(l)
|
||||
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('Сценарий: где купить книгу', () => {
|
||||
it('русский текст целиком, площадки списком без ссылок', () => {
|
||||
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) => {
|
||||
it.each(['ru', 'kk', 'en'] as const)('язык %s: Marwin и Flip.kz — ссылки в новой вкладке, без пометок', (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).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,6 +21,8 @@ export type HomeModel = {
|
||||
}
|
||||
|
||||
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'
|
||||
|
||||
const clean = (v?: string | null) => (v && v.trim() ? v.trim() : null)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user