From ee44016455e22e077fc9021a8e399f824b8daf3e Mon Sep 17 00:00:00 2001 From: Soichiro Miki Date: Thu, 2 Nov 2023 14:43:33 +0900 Subject: [PATCH] Redirect some external links to Japanese versions --- src/components/MDX/Link.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/MDX/Link.tsx b/src/components/MDX/Link.tsx index 7bf041e56..a42d52891 100644 --- a/src/components/MDX/Link.tsx +++ b/src/components/MDX/Link.tsx @@ -29,6 +29,16 @@ function Link({ // eslint-disable-next-line jsx-a11y/anchor-has-content return ; } + + // Tweak external links (added by ja.react.dev team) + href = href + .replace( + 'https://developer.mozilla.org/en-US/', + 'https://developer.mozilla.org/' + ) + .replace('https://reactjs.org/', 'https://ja.reactjs.org/') + .replace('https://legacy.reactjs.org/', 'https://ja.legacy.reactjs.org/'); + return ( <> {href.startsWith('https://') ? (