reactjs / ja.react.dev

React documentation website in Japanese
https://ja.react.dev
Creative Commons Attribution 4.0 International
261 stars 176 forks source link

Redirect some external links to Japanese versions #709

Closed smikitky closed 11 months ago

smikitky commented 12 months ago

MDN のリンク先が英語版になっている問題を JavaScript のソースコードベースで解消します。Link 関数は MDX の []() 構文の実装を置き換えるためのコンポーネントです。その部分に以下のようなコードを追加します。

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/');

MDN の URL から en-US を取り除くことで、基本言語が日本語になっているブラウザからのアクセス、かつ日本語記事が既に存在する場合、自動的にそちらにリダイレクトされるようになります。

問題点は 2 個あります。

github-actions[bot] commented 12 months ago

Size changes

## 📦 Next.js Bundle Analysis for react-dev This analysis was generated by the [Next.js Bundle Analysis action](https://github.com/hashicorp/nextjs-bundle-analysis). 🤖 ### Three Pages Changed Size The following pages changed size from the code in this PR compared to its base branch: Page | Size (compressed) | First Load | |---|---|---| | `/404` | `79.51 KB` _(🟡 +75 B)_ | 183.49 KB | | `/500` | `79.51 KB` _(🟡 +75 B)_ | 183.49 KB | | `/[[...markdownPath]]` | `81.31 KB` _(🟡 +75 B)_ | 185.29 KB |
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.