2025-09-27 16:07:45 -05:00
|
|
|
import locales from "@blitzkit/i18n/locales.json";
|
|
|
|
|
import { Link, type LinkProps } from "@radix-ui/themes";
|
|
|
|
|
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 =
|
2025-09-27 16:07:45 -05:00
|
|
|
locale === undefined || locale === locales.default ? "" : `/${locale}`;
|
2024-12-27 13:43:25 -06:00
|
|
|
|
|
|
|
|
return (
|
2025-09-27 16:07:45 -05:00
|
|
|
<Link href={href?.startsWith("/") ? `${prefix}${href}` : href} {...props} />
|
2024-12-27 13:43:25 -06:00
|
|
|
);
|
|
|
|
|
}
|