-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow configuring locale base URL #6731
base: main
Are you sure you want to change the base?
feat: allow configuring locale base URL #6731
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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
|
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 start
The url of English docs homepage is
http://localhost:3000/
.The url of English docs homepage is
http://localhost:3000/zh-CN/
.yarn build
The generated static file directories are build and build/zh-CN.
yarn workspace website serve
The 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 start
The url of English docs homepage is
http://localhost:3000/en-US/
.The url of English docs homepage is
http://localhost:3000/zh-CN/
.yarn build
The generated static file directories are
build/en-US
andbuild/zh-CN
.yarn workspace website serve
The 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)