feat: auto prefixor

This commit is contained in:
tresabhi committed 2025-01-10 14:37:29 -06:00
1 parent ffe58de179
commit 260d819c77
6 files changed
+65 -34

No files matched your search

+1 -4
View File
@@ -1,13 +1,10 @@
import { Link, type LinkProps } from '@radix-ui/themes';
import { getBestLocale } from '../core/i18n/getBestLocale';
import type { LocaleAcceptorProps } from '../hooks/useLocale';
type LinkI18nProps = LinkProps & LocaleAcceptorProps;
export function LinkI18n({ locale, href, ...props }: LinkI18nProps) {
const bestLocale = getBestLocale();
const resolvedLocale = locale ?? bestLocale;
const prefix = resolvedLocale === undefined ? '' : `/${resolvedLocale}`;
const prefix = locale === undefined ? '' : `/${locale}`;
return (
<Link href={href?.startsWith('/') ? `${prefix}${href}` : href} {...props} />