SEO
This commit is contained in:
@@ -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}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user