Skip to content

Commit

Permalink
feat(frontend): link component
Browse files Browse the repository at this point in the history
  • Loading branch information
JaydenXu-BTC committed Jul 11, 2024
1 parent fab7340 commit a8d5215
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/src/components/ui/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ export interface LinkProps
const StyledLink = styled(NextLink)

export const Link = forwardRef<HTMLAnchorElement, LinkProps>(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}`,
Expand All @@ -32,3 +31,5 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link({ chi
</StyledLink>
)
})

export default Link

0 comments on commit a8d5215

Please sign in to comment.