mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-14 13:16:11 +01:00
19 lines
535 B
TypeScript
19 lines
535 B
TypeScript
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}
|
||
|
|
/>
|
||
|
|
);
|
||
|
|
}
|