feat: allow configuring locale base URL#6731
feat: allow configuring locale base URL#6731xiaosongxiaosong wants to merge 8 commits intofacebook:mainfrom
Conversation
|
✔️ [V2] 🔨 Explore the source changes: 106d57e 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/621378847b017b0007d7357e 😎 Browse the preview: https://deploy-preview-6731--docusaurus-2.netlify.app |
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6731--docusaurus-2.netlify.app/ |
Josh-Cena
left a comment
There was a problem hiding this comment.
This is certainly something we want (#6075), because currently the base URL is coupled to the locale name—no good. I've made a few comments in ossrs/srs-docs#11 which I'll restate here:
- Why not Nginx redirects? I've seen you've raised that possibility in your repo's issue, but have you investigated?
- If two locales both contain a base URL, the root of your website will become inaccessible because
http://ossrs.io/will be 404. I think that's bad UX.
|
There are a few things missing in this PR. Not everything is working (from a quick eyeballing, because we don't have tests for this) and it's not really in the direction I'd like. Don't worry @xiaosongxiaosong I will do the further refactoring needed. Basically, the logic would be like:
|
|
Implemented in #11316 |
Motivation
Make the locale baseUrl support configurable.
In my case, i want the url of English docs(default locale) to be like
http://localhost:3000/en-US/, the url of Chinese docs to be likehttp://localhost:3000/zh-CN/.Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
Default Config Test
use docusaurus website i18n config to test
yarn startThe url of English docs homepage is
http://localhost:3000/.The url of English docs homepage is
http://localhost:3000/zh-CN/.yarn buildThe generated static file directories are build and build/zh-CN.
yarn workspace website serveThe url of English docs homepage is
http://localhost:3000/.The url of English docs homepage is
http://localhost:3000/zh-CN/.Custom Config Test
yarn startThe url of English docs homepage is
http://localhost:3000/en-US/.The url of English docs homepage is
http://localhost:3000/zh-CN/.yarn buildThe generated static file directories are
build/en-USandbuild/zh-CN.yarn workspace website serveThe url of English docs homepage is
http://localhost:3000/en-US/.The url of English docs homepage is
http://localhost:3000/zh-CN/.Related PRs
#4723 (comment)