2025-01-14 19:22:41 -06:00
|
|
|
import { DEFAULT_LOCALE } from '@blitzkit/i18n';
|
2024-12-27 13:43:25 -06:00
|
|
|
import { Link, type LinkProps } from '@radix-ui/themes';
|
2025-01-06 20:31:21 -06:00
|
|
|
import type { LocaleAcceptorProps } from '../hooks/useLocale';
|
2024-12-27 13:43:25 -06:00
|
|
|
|
2025-01-06 20:31:21 -06:00
|
|
|
type LinkI18nProps = LinkProps & LocaleAcceptorProps;
|
2024-12-27 13:43:25 -06:00
|
|
|
|
|
|
|
|
export function LinkI18n({ locale, href, ...props }: LinkI18nProps) {
|
2025-01-13 20:06:43 -06:00
|
|
|
const prefix =
|
|
|
|
|
locale === undefined || locale === DEFAULT_LOCALE ? '' : `/${locale}`;
|
2024-12-27 13:43:25 -06:00
|
|
|
|
|
|
|
|
return (
|
2024-12-27 14:01:59 -06:00
|
|
|
<Link href={href?.startsWith('/') ? `${prefix}${href}` : href} {...props} />
|
2024-12-27 13:43:25 -06:00
|
|
|
);
|
|
|
|
|
}
|