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

14 lines
487 B
TypeScript
Raw Normal View History

2025-01-13 20:06:43 -06:00
import { DEFAULT_LOCALE } from '@blitzkit/core';
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
);
}