Fix dynamic default locale routing

This commit is contained in:
MOH
2026-03-15 04:41:08 +01:00
parent 50c3f5cce9
commit 364f761420
13 changed files with 73 additions and 32 deletions
+10 -4
View File
@@ -34,6 +34,7 @@ const disabledMobileNavItemClassName =
type SiteHeaderProps = {
lightLogoUrl?: string | null;
darkLogoUrl?: string | null;
defaultLocale: "de" | "en" | "ar";
};
function getDirectionalReveal(direction: "rtl" | "ltr") {
@@ -57,9 +58,11 @@ function isNavItemActive(currentPath: string, itemPath: string) {
}
function NavLinks({
defaultLocale,
onNavigate,
mobile = false,
}: {
defaultLocale: "de" | "en" | "ar";
onNavigate?: () => void;
mobile?: boolean;
}) {
@@ -113,7 +116,7 @@ function NavLinks({
return (
<Link
key={item.key}
href={getLocalizedPath(locale, itemPath)}
href={getLocalizedPath(locale, itemPath, defaultLocale)}
className={cn(
"relative z-10 rounded-pill transition-colors",
mobile ? "px-4 py-3 text-sm font-medium" : "px-3.5 py-2 text-sm font-medium xl:px-4",
@@ -142,6 +145,7 @@ function NavLinks({
export function SiteHeader({
lightLogoUrl,
darkLogoUrl,
defaultLocale,
}: SiteHeaderProps) {
const [isOpen, setIsOpen] = useState(false);
const [isScrolled, setIsScrolled] = useState(false);
@@ -210,7 +214,7 @@ export function SiteHeader({
)}
>
<Link
href={getLocalizedPath(locale)}
href={getLocalizedPath(locale, "/", defaultLocale)}
className="inline-flex items-center gap-2.5 rounded-pill px-1 py-1 sm:gap-3 lg:py-2"
onClick={handleLogoClick}
>
@@ -277,7 +281,7 @@ export function SiteHeader({
isArabic ? "w-auto max-w-none" : "min-w-[27rem] max-w-[42rem]",
)}
>
<NavLinks />
<NavLinks defaultLocale={defaultLocale} />
</motion.nav>
</div>
@@ -293,6 +297,7 @@ export function SiteHeader({
<div className={desktopControlRailClassName}>
<LocaleToggle
locale={locale}
defaultLocale={defaultLocale}
className={desktopControlButtonClassName}
/>
<SoundToggle
@@ -405,7 +410,7 @@ export function SiteHeader({
</div>
) : (
<Link
href={getLocalizedPath(locale, itemPath)}
href={getLocalizedPath(locale, itemPath, defaultLocale)}
className={cn(
"flex items-center justify-between rounded-nested px-4 py-3 text-sm font-medium transition-colors",
isActive
@@ -435,6 +440,7 @@ export function SiteHeader({
<div className="flex items-center justify-between gap-2">
<LocaleToggle
locale={locale}
defaultLocale={defaultLocale}
className={mobileControlButtonClassName}
/>
<div className="flex items-center gap-2">