docusaurus: Broken links in example `index.js` because of language
Is this a bug report?
Yes. In the example index.js we have a line let language = this.props.language.... However, in generate.js and particularly metadata.js we are actually setting the permalink on the assumption that the language isn’t set.
if (languages.length === 1 && !siteConfig.useEnglishUrl) {
metadata.permalink = 'docs/' + metadata.id + '.html';
} else {
metadata.permalink = 'docs/' + language + '/' + metadata.id + '.html';
}
But in the code before this, we are actually setting this.props.language to en by default, I think. So we are conflicting.
There are a few ways I can fix this, but I need to come up with the best way.
Have you read the [Contributing Guidelines]
Yes, of course. I helped right them 😃
Environment
N/A
Steps to Reproduce
yarn global add docusaurus-initdocusaurus-initmv docs-examples-from-docusaurus docs&&mv website/blog-examples-from-docusaurus website/blogcd websiteyarn run start- Go to http://localhost:3000
- Click on the
Example LinkButton - See 404.
Expected Behavior
The button links should go to an actual docs page.
Actual Behavior
The button links go to a 404-ish page.
Reproducible Demo
Run the steps above.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (15 by maintainers)
It was a stupid error. I ran prettier but didn’t commit prettier changes…
Yes, I think @neilsutcliffe and I are on the same direction. We all agree if no language.js, there shouldn’t be language prefix. This approach is a more fundamental change rather than a quick fix. Need to be careful here.
Made a PR for it. Not a small change. More reviews are better. 😃