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

  1. yarn global add docusaurus-init
  2. docusaurus-init
  3. mv docs-examples-from-docusaurus docs && mv website/blog-examples-from-docusaurus website/blog
  4. cd website
  5. yarn run start
  6. Go to http://localhost:3000
  7. Click on the Example Link Button
  8. 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.

screenshot 2017-12-17 15 53 41 screenshot 2017-12-17 15 54 00

Reproducible Demo

Run the steps above.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

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. 😃