36 lines
1.8 KiB
TypeScript
36 lines
1.8 KiB
TypeScript
import Link from 'next/link'
|
|
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 links = [
|
|
['/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 (
|
|
<header className="absolute inset-x-0 top-0 z-10">
|
|
<div className="mx-auto flex max-w-6xl flex-wrap items-center justify-between gap-x-8 gap-y-3 px-5 py-6 sm:px-8">
|
|
<Link href={`/${locale}`} className="font-serif text-lg tracking-wide">
|
|
{t.siteName}
|
|
</Link>
|
|
<nav className="order-3 flex w-full flex-wrap gap-x-6 gap-y-2 text-sm text-graphite md:order-2 md:w-auto">
|
|
{links.filter((l) => l[2]).map(([href, label]) => (
|
|
<a key={href} href={`/${locale}${href}`} className="hover:text-burgundy">{label}</a>
|
|
))}
|
|
</nav>
|
|
<div className="order-2 flex gap-3 text-sm md:order-3" aria-label={t.language}>
|
|
{locales.map((l) => (
|
|
<Link key={l} href={`/${l}${path}`} hrefLang={l} aria-current={l === locale ? 'true' : undefined}
|
|
className={l === locale ? 'font-bold text-burgundy underline decoration-2 underline-offset-4' : 'font-normal text-graphite hover:text-burgundy'}>
|
|
{l.toUpperCase()}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</header>
|
|
)
|
|
}
|