From a8d5215a0ffe51d3525c6ccb43f35a12ee9a764c Mon Sep 17 00:00:00 2001 From: INS Date: Thu, 11 Jul 2024 20:49:26 +0800 Subject: [PATCH] feat(frontend): link component --- frontend/src/components/ui/link.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/ui/link.tsx b/frontend/src/components/ui/link.tsx index b3403511..31a71d1f 100644 --- a/frontend/src/components/ui/link.tsx +++ b/frontend/src/components/ui/link.tsx @@ -16,12 +16,11 @@ export interface LinkProps const StyledLink = styled(NextLink) export const Link = forwardRef(function Link({ children, ...props }, ref) { - const { - i18n: { locale }, - } = useLingui() + const { i18n } = useLingui() + const locale = props.locale ?? i18n.locale const href = typeof props.href === 'string' - ? `/${props.locale ?? locale}${props.href}` + ? `/${locale}${props.href}` : { ...props.href, pathname: `/${locale}${props.href.pathname}`, @@ -32,3 +31,5 @@ export const Link = forwardRef(function Link({ chi ) }) + +export default Link