Docusaurus: sidebar.json does not allow for subcategories

Created on 22 Jan 2018  路  13Comments  路  Source: facebook/docusaurus

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

OS: MacOS High Sierra
Node: 8.6.0
npm: 5.6.0

Steps to Reproduce

  1. Create an app following docusaurus docs
  2. Try creating a subcategory using the sidebar.json:
{
  "docs": {
    "Docusaurus": ["doc1"],
    "Category 1": {
        "Subcategory": ["doc2", "doc3"]
    },
    "Category 2": ["doc4"]
   },
  "docs-other": {
    "First Category": ["doc5", "doc6"]
  }
}
  1. Launch the website and access documentation

Expected Behavior

I would expect to see the documentation page with a sidebar that contains subcategories.

Actual Behavior

Site blows up with the following error:

Error: Improper sidebars.json file, document with id '[object Object]' not found. Make sure that documents with the ids specified in sidebars.json exist and that no ids are repeated.
    at _loop (/Users/pedro/Workspace/fsort-website/website/node_modules/docusaurus/lib/server/readCategories.js:58:17)
    at readCategories (/Users/pedro/Workspace/fsort-website/website/node_modules/docusaurus/lib/server/readCategories.js:34:53)
    at DocsSidebar.render (/Users/pedro/Workspace/fsort-website/website/node_modules/docusaurus/lib/core/DocsSidebar.js:18:26)
    at /Users/pedro/Workspace/fsort-website/website/node_modules/react-dom/lib/ReactCompositeComponent.js:793:21
    at measureLifeCyclePerf (/Users/pedro/Workspace/fsort-website/website/node_modules/react-dom/lib/ReactCompositeComponent.js:73:12)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (/Users/pedro/Workspace/fsort-website/website/node_modules/react-dom/lib/ReactCompositeComponent.js:792:25)
    at ReactCompositeComponentWrapper._renderValidatedComponent (/Users/pedro/Workspace/fsort-website/website/node_modules/react-dom/lib/ReactCompositeComponent.js:819:32)
    at ReactCompositeComponentWrapper.performInitialMount (/Users/pedro/Workspace/fsort-website/website/node_modules/react-dom/lib/ReactCompositeComponent.js:359:30)
    at ReactCompositeComponentWrapper.mountComponent (/Users/pedro/Workspace/fsort-website/website/node_modules/react-dom/lib/ReactCompositeComponent.js:255:21)
    at Object.mountComponent (/Users/pedro/Workspace/fsort-website/website/node_modules/react-dom/lib/ReactReconciler.js:43:35)

Reproducible Demo

Here is a link to a demo that demonstrates the issue. Simply copy, run npm i on the website folder and you are ready to go:

https://github.com/Fl4m3Ph03n1x/docusaurus-bug-report

intermediate feature claimed

Most helpful comment

It doesn't look like this is being worked on so I'll work on implementing this.

All 13 comments

@Fl4m3Ph03n1x Hi!

Just so I am clear, you want a sidebar that looks something like:

  - Doc
CATEGORY
  - Doc
  SUB-CATEGORY
      - Doc
CATEGORY
  - DOC

If so, not sure this a bug more of a feature request. Just like with links to anchors in the sidebar, etc. this is a reasonable request. Thanks!

OHhh, I assumed it was possible but that it was not working as intended. Feature Request it is then!
Your understanding of the issue is correct.

Feel free to check my basic github repo for additional information, I did it with all the coding love in the world :P

Anyway, thanks for acknowledging this ticket! I look forward to seeing this feature implemented !

PS: Now that we established that this is a FR, what are the next steps? Is there any process ?

Hi @Fl4m3Ph03n1x - You are welcome 馃槃

The process would be to implement this feature. Would love a PR; otherwise, it will most likely come when we do our next feature set for Docusaurus. Or if I just get some time to do it before that.

Hello @JoelMarcey ,
I'm new to contributing, but I want to take on this feature.

Here's a screenshot of what it will look like in the page.

image

@diboy2 Hi! I would love it if you wanted to send a PR for this feature. I am a bit confused on the screenshot though. I see a bunch of duplicates in there. For example, why do I see "Site Preparation" three times.

@JoelMarcey Hello there! I am a newbie who is using docusaurus, I have learned and have created my own website, of course, including the sidebar, but now I want to implement the subdirectory after clicking on the directory in the sidebar, again Let it shrink when clicked. The official documentation of the use of JS makes me confused, I hope you can help me, thank you.

@XzMitsui Since this issue is still open, I would assume the feature you are asking was not yet implemented.

@Fl4m3Ph03n1x Yes,it is. I tried it many times and it didn't work, and a development and maintenance person told me that this feature has not been implemented.

Yes,it is. I tried it many times and it didn't work, and a development and maintenance person told me that this feature has not been implemented.

Make up your mind. Either it is implemented or it isn't.
I am stating that this feature is not yet implemented. You start your comment by saying I am wrong only to end it saying I am right.

@Fl4m3Ph03n1x I don't understand what you mean. I mean, I didn't have a solution after trying it, and then opened up a new Issues, and a maintenance person told me so.

It doesn't look like this is being worked on so I'll work on implementing this.

Thanks @WillBrock!

We've added an "issue: claimed" label so that others will know not to start work on the issue. If you change your mind about the issue, no worries! Just let me know so that we can remove the label and free it up for someone else to claim.

We will check in with you periodically so that we can keep the task updated with the progress.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rickyvetter picture rickyvetter  路  3Comments

endiliey picture endiliey  路  3Comments

ericnakagawa picture ericnakagawa  路  3Comments

omry picture omry  路  3Comments

chandankumar4 picture chandankumar4  路  3Comments