File tree Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { ErrorBoundary as SentryErrorBoundary } from "@sentry/react";
22import { FC , PropsWithChildren } from "react" ;
33
44import { Grid } from "../grid" ;
5- import { Link } from "../link" ;
5+ import { Link } from "../link-factory " ;
66import { Typography } from "../typography" ;
77
88type ErrorBoundaryProps = PropsWithChildren < {
Original file line number Diff line number Diff line change 1+ import { FC , HTMLProps } from "react" ;
2+ import { Link as ReactRouterLink , LinkProps } from "react-router-dom" ;
3+
4+ export const linkFactory =
5+ ( getLanguageCode : ( ) => string , defaultLanguageCode : string ) : FC < HTMLProps < HTMLAnchorElement > > =>
6+ // eslint-disable-next-line react/display-name
7+ ( props ) => {
8+ const languageCode = getLanguageCode ( ) ;
9+
10+ if ( props . href && ( props . href . startsWith ( "/" ) || props . href . startsWith ( location . origin ) ) ) {
11+ return (
12+ < ReactRouterLink
13+ { ...( props as LinkProps ) }
14+ to = { defaultLanguageCode === languageCode ? props . href : `/${ languageCode } ${ props . href } ` }
15+ />
16+ ) ;
17+ } else {
18+ return < a { ...props } /> ;
19+ }
20+ } ;
21+
22+ export const Link = linkFactory ( ( ) => "en" , "en" ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments