Files
blitzkit/packages/website/src/components/LinkI18n.tsx
T

19 lines
535 B
TypeScript
Raw Normal View History

2024-12-27 13:43:25 -06:00
import { Link, type LinkProps } from '@radix-ui/themes';
import { getBestLocale } from '../core/i18n/getBestLocale';
type LinkI18nProps = LinkProps & {
locale: string | undefined;
};
export function LinkI18n({ locale, href, ...props }: LinkI18nProps) {
const bestLocale = getBestLocale();
const resolvedLocale = locale ?? bestLocale;
const prefix = resolvedLocale === undefined ? '' : `/${resolvedLocale}`;
return (
<Link
href={href === undefined ? undefined : `${prefix}${href}`}
{...props}
/>
);
}