--- import ThemeToggle from './ThemeToggle.astro'; import { getLocalizedPath, LANG_LABELS, useTranslations, type Lang } from '../lib/i18n'; interface Props { lang: Lang; /** See BaseLayout. */ alternates: Partial>; } const { lang, alternates } = Astro.props; const t = useTranslations(lang); const otherLang: Lang = lang === 'en' ? 'pt' : 'en'; const pathname = Astro.url.pathname; const homeHref = getLocalizedPath('/', lang); const postsHref = getLocalizedPath('/posts', lang); const aboutHref = getLocalizedPath('/about', lang); // Not everything is translated: fall back to the other language's home page. const langSwitchHref = alternates[otherLang] ?? getLocalizedPath('/', otherLang); const navLinks = [ { href: homeHref, label: t('nav.home'), id: 'home' }, { href: postsHref, label: t('nav.posts'), id: 'posts' }, { href: aboutHref, label: t('nav.about'), id: 'about' }, ]; function isActive(href: string): boolean { if (href === homeHref) return pathname.replace(/\/$/, '') === href; return pathname === href || pathname.startsWith(`${href}/`); } ---