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

12 lines
405 B
TypeScript
Raw Normal View History

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-10 14:37:29 -06:00
const prefix = locale === undefined ? '' : `/${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
);
}