QLFW-57: показать почту и Instagram в подвале
This commit is contained in:
parent
17e59ab4c6
commit
fd32266c86
@ -1,8 +1,8 @@
|
||||
## 1. Контакты
|
||||
|
||||
- [ ] 1.1 Добавить в общий подвал блок контактов с почтой и Instagram, сохранив переход на страницу контактов.
|
||||
- [ ] 1.2 Проверить запасную ссылку рядом с обеими формами и контакты в подвале на RU, KK и EN.
|
||||
- [x] 1.1 Добавить в общий подвал блок контактов с почтой и Instagram, сохранив переход на страницу контактов.
|
||||
- [x] 1.2 Проверить запасную ссылку рядом с обеими формами и контакты в подвале на RU, KK и EN.
|
||||
|
||||
## 2. Проверки
|
||||
|
||||
- [ ] 2.1 Запустить проверки проекта и openspec validate.
|
||||
- [x] 2.1 Запустить проверки проекта и openspec validate.
|
||||
|
||||
@ -7,7 +7,7 @@ import { Header } from '@/components/Header'
|
||||
import { getDict, isLocale, locales } from '@/i18n'
|
||||
import { loadContent, loadLegal, loadSettings } from '@/lib/content'
|
||||
import { isLegalPublished } from '@/lib/legal-model'
|
||||
import { emailLinkHtml } from '@/lib/home-model'
|
||||
import { emailLinkHtml, foundationInstagram } from '@/lib/home-model'
|
||||
import { buildContacts } from '@/lib/site-model'
|
||||
import { FALLBACK_EMAIL } from '@/lib/inquiry'
|
||||
|
||||
@ -55,7 +55,7 @@ export default async function ContactsPage({ params }: Props) {
|
||||
</p>
|
||||
)}
|
||||
<p className="mt-2">
|
||||
<a href="https://www.instagram.com/serkebayev_book/" className="text-burgundy underline underline-offset-4 hover:no-underline">{t.collaboration.instagram}</a>
|
||||
<a href={foundationInstagram} className="text-burgundy underline underline-offset-4 hover:no-underline">{t.collaboration.instagram}</a>
|
||||
</p>
|
||||
<div className="mt-10">
|
||||
<ContactForm t={t} locale={locale} email={email} privacyLink={isLegalPublished(legal?.privacy)} />
|
||||
|
||||
@ -10,7 +10,7 @@ import Link from 'next/link'
|
||||
import { getDict, isLocale } from '@/i18n'
|
||||
import { loadContent, loadProjects, loadSettings } from '@/lib/content'
|
||||
import { buildContacts, mediaOf, visibleProjects } from '@/lib/site-model'
|
||||
import { buildHomeModel, type Card } from '@/lib/home-model'
|
||||
import { foundationInstagram, buildHomeModel, type Card } from '@/lib/home-model'
|
||||
import { FALLBACK_EMAIL } from '@/lib/inquiry'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
@ -140,7 +140,7 @@ export default async function Home({ params }: { params: Promise<{ locale: strin
|
||||
<div className="mt-10">
|
||||
<ContactForm t={t} locale={locale} email={email} dark privacyLink={isLegalPublished(legal?.privacy)} />
|
||||
</div>
|
||||
<a href="https://www.instagram.com/serkebayev_book/" className="mt-6 inline-flex min-h-11 items-center gap-3 underline underline-offset-4 hover:text-paper/75">
|
||||
<a href={foundationInstagram} className="mt-6 inline-flex min-h-11 items-center gap-3 underline underline-offset-4 hover:text-paper/75">
|
||||
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" className="h-6 w-6 shrink-0">
|
||||
<rect x="3" y="3" width="18" height="18" rx="5" />
|
||||
<circle cx="12" cy="12" r="4" />
|
||||
|
||||
@ -1,19 +1,34 @@
|
||||
import Link from 'next/link'
|
||||
import type { Dict, Locale } from '@/i18n'
|
||||
import { emailLinkHtml, foundationEmail, foundationInstagram } from '@/lib/home-model'
|
||||
import { isLegalPublished, type CmsLegal } from '@/lib/legal-model'
|
||||
|
||||
export function Footer({ t, locale, legal }: { t: Dict; locale: Locale; legal: CmsLegal | null }) {
|
||||
const showPrivacy = isLegalPublished(legal?.privacy)
|
||||
const showTerms = isLegalPublished(legal?.terms)
|
||||
const contactLink = 'underline underline-offset-4 hover:text-burgundy'
|
||||
|
||||
return (
|
||||
<footer className="border-t border-line">
|
||||
<div className="mx-auto flex max-w-6xl flex-col gap-4 px-5 py-10 text-sm text-muted sm:px-8 md:flex-row md:items-center md:justify-between">
|
||||
<p>
|
||||
© {new Date().getFullYear()} {t.siteName}. {t.footer}
|
||||
</p>
|
||||
<nav className="flex flex-wrap gap-x-6 gap-y-2">
|
||||
<Link href={`/${locale}/contacts`} className="hover:text-burgundy">{t.contacts.title}</Link>
|
||||
{isLegalPublished(legal?.privacy) && <Link href={`/${locale}/privacy`} className="hover:text-burgundy">{t.legal.privacy.title}</Link>}
|
||||
{isLegalPublished(legal?.terms) && <Link href={`/${locale}/terms`} className="hover:text-burgundy">{t.legal.termsShort}</Link>}
|
||||
</nav>
|
||||
<div className="mx-auto flex max-w-6xl flex-col gap-6 px-5 py-10 text-sm text-muted sm:px-8 md:flex-row md:justify-between">
|
||||
<div>
|
||||
<h2 className="font-semibold text-graphite">
|
||||
<Link href={`/${locale}/contacts`} className="hover:text-burgundy">{t.contacts.title}</Link>
|
||||
</h2>
|
||||
<ul className="mt-2 space-y-2">
|
||||
<li dangerouslySetInnerHTML={{ __html: emailLinkHtml(foundationEmail, contactLink) }} />
|
||||
<li><a href={foundationInstagram} className={contactLink}>{t.collaboration.instagram}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<p>© {new Date().getFullYear()} {t.siteName}. {t.footer}</p>
|
||||
{(showPrivacy || showTerms) && (
|
||||
<nav className="flex flex-wrap gap-x-6 gap-y-2">
|
||||
{showPrivacy && <Link href={`/${locale}/privacy`} className="hover:text-burgundy">{t.legal.privacy.title}</Link>}
|
||||
{showTerms && <Link href={`/${locale}/terms`} className="hover:text-burgundy">{t.legal.termsShort}</Link>}
|
||||
</nav>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
)
|
||||
|
||||
35
src/lib/contact-links.test.ts
Normal file
35
src/lib/contact-links.test.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { expect, it, vi } from 'vitest'
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import Home from '../app/(site)/[locale]/page'
|
||||
import Contacts from '../app/(site)/[locale]/contacts/page'
|
||||
import { getDict, locales } from '../i18n'
|
||||
|
||||
vi.mock('@/app/actions/inquiry', () => ({ submitInquiry: vi.fn() }))
|
||||
vi.mock('./content', () => ({
|
||||
loadContent: vi.fn(async () => ({ home: null, news: [] })),
|
||||
loadLegal: vi.fn(async () => null),
|
||||
loadProjects: vi.fn(async () => []),
|
||||
loadSettings: vi.fn(async () => null),
|
||||
}))
|
||||
|
||||
for (const locale of locales) {
|
||||
for (const [page, Page] of [['Главная', Home], ['Контакты', Contacts]] as const) {
|
||||
it(`${page} (${locale}): прямые контакты в форме и подвале без JavaScript`, async () => {
|
||||
const html = renderToStaticMarkup(await Page({ params: Promise.resolve({ locale }) }))
|
||||
const t = getDict(locale)
|
||||
const form = html.match(/<form\b[\s\S]*?<\/form>/)?.[0]
|
||||
const footer = html.match(/<footer\b[\s\S]*?<\/footer>/)?.[0]
|
||||
const emailLink = /<!--email_off--><a href="mailto:qazaqlegacy@gmail\.com"[^>]*>qazaqlegacy@gmail\.com<\/a><!--\/email_off-->/
|
||||
|
||||
expect(form).toContain(t.form.fallback)
|
||||
expect(form).toMatch(emailLink)
|
||||
expect(footer).toMatch(emailLink)
|
||||
expect(footer).toContain(`href="/${locale}/contacts"`)
|
||||
expect(footer).toContain(`>${t.contacts.title}</a></h2>`)
|
||||
expect(footer).toContain('href="https://www.instagram.com/serkebayev_book/"')
|
||||
expect(footer).toContain(`>${t.collaboration.instagram}</a>`)
|
||||
expect(footer).not.toContain(`/${locale}/privacy`)
|
||||
expect(footer).not.toContain(`/${locale}/terms`)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,7 @@ export type HomeModel = {
|
||||
}
|
||||
|
||||
export const foundationEmail = 'qazaqlegacy@gmail.com'
|
||||
export const foundationInstagram = 'https://www.instagram.com/serkebayev_book/'
|
||||
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