Docusaurus: `npm run version` generates broken sidebars when subcategories exist

Created on 15 Nov 2018  路  2Comments  路  Source: facebook/docusaurus

馃悰 Bug Report

Running npm run version <x> generates broken sidebars on version 1.5.1.

Have you read the Contributing Guidelines on issues?

Yup

To Reproduce

Sidebar definition sidebar.json


    "ORY Hydra": [
      "hydra/hydra-index",
      {
        "type": "subcategory",
        "label": "Getting Started",
        "ids": [
          "hydra/hydra-5min-tutorial"
        ]
      },
      {
        "type": "subcategory",
        "label": "Guides",
        "ids": [
          "hydra/hydra-oauth2",
          "hydra/hydra-jwks",
          "hydra/hydra-configure-deploy",
          "hydra/hydra-advanced",
          "hydra/hydra-debugging",
          "hydra/hydra-production",
          "hydra/hydra-integration"
        ]
      },
      {
        "type": "subcategory",
        "label": "SDK",
        "ids": [
          "hydra/hydra-sdk-sdk/hydra-sdk-index",
          "hydra/hydra-sdk-sdk/hydra-sdk-api",
          "hydra/hydra-sdk-sdk/hydra-sdk-go",
          "hydra/hydra-sdk-sdk/hydra-sdk-js"
        ]
      },
      {
        "type": "subcategory",
        "label": "Further Reading",
        "ids": [
          "hydra/hydra-limitations",
          "hydra/hydra-dependencies-environment",
          "hydra/hydra-security-architecture",
          "hydra/hydra-faq",
          "hydra/hydra-appendix"
        ]
      }
    ],

yields after running npm run version oryOS.9 in ./versioned_sidebars/version-oryOS.9-sidebar.json

{
  "version-oryOS.9-docs": {
    // ...
    "ORY Hydra": [
      "version-oryOS.9-hydra/hydra-index",
      "version-oryOS.9-[object Object]",
      "version-oryOS.9-[object Object]",
      "version-oryOS.9-[object Object]",
      "version-oryOS.9-[object Object]"
    ],
    // ...

Expected behavior

The sidebar should not contain broken links.

Actual Behavior

The sidebar contains broken links.

Reproducible Demo

  1. git clone https://github.com/ory/docs.git
  2. cd docs
  3. git checkout dd96ee81cf315284ee88dd7d2fe5cb10c60be67d -b reproduceme2
  4. cd website
  5. npm i
  6. npm run version oryOS.9
  7. cat ./website/versioned_sidebars/version-oryOS.9-sidebars.json
bug good first issue

Most helpful comment

Pretty sure this is related to #410 where this has been resolved in part but apparently not for versioned docs.

All 2 comments

Pretty sure this is related to #410 where this has been resolved in part but apparently not for versioned docs.

This is related to incomplete PR of subcategories feature. We should update the logic for https://github.com/facebook/Docusaurus/blob/master/v1/lib/version.js

Specifically

Test Case:

{
  "docs": {
    "My Example Category": [
      "examples",
      {
        "type": "subcategory",
        "label": "My Example Subcategory",
        "ids": [
          "my-examples",
          ...
        ]
      },
    ],
    ...
  }
}

Cutting the version 1.0.0

Current Behavior:

versioned_sidebars/version-1.0.0-sidebars.json

{
  "version-1.0.0-docs": {
    "My Example Category": [
      "version-1.0.0-examples",
      "version-1.0.0-[object Object]",
    ],
    ...
  }
}

Expected Behavior:
versioned_sidebars/version-1.0.0-sidebars.json

{
  "version-1.0.0-docs": {
    "My Example Category": [
      "version-1.0.0-examples",
      {
        "type": "subcategory",
        "label": "My Example Subcategory",
        "ids": [
          "version-1.0.0-my-examples",
          ...
        ]
      },
    ],
    ...
  }
}

Accepting PRs on this 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yanzhiwei147 picture yanzhiwei147  路  69Comments

arifszn picture arifszn  路  24Comments

slorber picture slorber  路  23Comments

nebrelbug picture nebrelbug  路  26Comments

yangshun picture yangshun  路  27Comments