This commit is contained in:
2026-05-27 20:35:54 +02:00
parent 26713b13b1
commit 9d80dc8875
20 changed files with 979 additions and 175 deletions

View File

@@ -6,11 +6,11 @@ import { useEffect, useState } from 'react'
import { useLang } from '@/context/LangContext'
import type { Lang } from '@/lib/i18n'
const LANGS: { code: Lang; label: string; flag: string }[] = [
{ code: 'de', label: 'DE', flag: 'DE' },
{ code: 'en', label: 'EN', flag: 'EN' },
{ code: 'es', label: 'ES', flag: 'ES' },
]
const LANGS: { code: Lang; label: string; flag: string }[] = [
{ code: 'de', label: 'DE', flag: 'DE' },
{ code: 'en', label: 'EN', flag: 'EN' },
{ code: 'es', label: 'ES', flag: 'ES' },
]
export default function Navbar() {
const [scrolled, setScrolled] = useState(false)
@@ -45,10 +45,19 @@ export default function Navbar() {
<button
key={l.code}
className={`lang-btn${lang === l.code ? ' lang-btn--active' : ''}`}
onClick={() => {
setLang(l.code)
setMenuOpen(false)
}}
onClick={() => {
setLang(l.code)
setMenuOpen(false)
if (l.code === 'de' && pathname !== '/') {
window.location.href = '/'
}
if (l.code === 'es' && !pathname.startsWith('/es')) {
window.location.href = '/es'
}
if (l.code === 'en' && (pathname.startsWith('/de') || pathname.startsWith('/es'))) {
window.location.href = '/'
}
}}
aria-label={`Switch to ${l.label}`}
aria-pressed={lang === l.code}
>