Docusaurus: docsVersionDropdown defaults to an arbitrary page

Created on 11 Aug 2020  路  4Comments  路  Source: facebook/docusaurus

I want to open by saying I love the new version dropdown.
I enabled it today and I ran into an issue where it picks some odd page in some scenarios.

Repro:

  1. Go to hydra.cc.
  2. Select a version from the top bar.
  3. You will get to https://hydra.cc/docs/advanced/app_packaging or https://hydra.cc/docs/next/advanced/app_packaging based on the selected version.

I would like it to get to https://hydra.cc/docs/intro or https://hydra.cc/docs/next/intro when there isn't a defined page.

2.0.0-alpha.61:

$ cat website/package.json 
{
  "name": "website",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy"
  },
  "dependencies": {
    "@docusaurus/core": "^2.0.0-alpha.61",
    "@docusaurus/preset-classic": "^2.0.0-alpha.61",
    "classnames": "^2.2.6",
    "docusaurus-plugin-internaldocs-fb": "^0.3.3",
    "react": "^16.8.4",
    "react-dom": "^16.8.4"
  },
  "resolutions": {
    "prism-react-renderer": "1.1.0"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
bug needs triage

All 4 comments

I was able to check the problem. First of all, when you hover over the versions dropdown in any other page except for Docs, the links point to app_packaging,

Screen Shot 2020-08-11 at 10 38 44 PM

However, when in Docs Intro section, the links point to the intro,
Screen Shot 2020-08-11 at 10 38 28 PM

I am not if the current behavior is correct, if it's not I would like to work on this.

thanks :)

Yes this is an issue I have seen in the code. I'm going through a docs plugin refactor, which would make this much easier to fix (https://github.com/facebook/docusaurus/pull/3245)

The problem is the algo to know where to link to in this dropdown:

  • use the homePageId (if it exists)
  • use the doc with slug: /
  • use the first doc on the list

The problem is that "the list" is unordered. I'll make sure that the is ordered, ie we'd get the first doc of the first sidebar instead.

In the meantime you should be able to fix your problem by using the homePageId feature, but you'll end up with /docs/ instead of /docs/intro

Fixed in https://github.com/facebook/docusaurus/pull/3245

The fallback doc will be the first doc of the first sidebar (maybe we'll make it configurable but that seems a good enough heuristic for now, better than random doc)

Yeah, I agree this is a good for now. Thanks for fixing!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ericnakagawa picture ericnakagawa  路  3Comments

awibox picture awibox  路  3Comments

sebqq picture sebqq  路  3Comments

endiliey picture endiliey  路  3Comments

ericnakagawa picture ericnakagawa  路  3Comments