Skip to content

Add ability to specify sub categories in sidebar.json#891

Merged
yangshun merged 1 commit intofacebook:masterfrom
WillBrock:will-sub-categories
Aug 7, 2018
Merged

Add ability to specify sub categories in sidebar.json#891
yangshun merged 1 commit intofacebook:masterfrom
WillBrock:will-sub-categories

Conversation

@WillBrock
Copy link
Contributor

Motivation

Some users would like to be able to specify sub categories in the sidebar as discussed in #410.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Added unit tests for the functions that were modified and visually verified existing sidebars function the same as well as the new sub categories.

sub-category-sidebar

Example sidebars:

{
  "docs": {
    "First Category": {
      "Sub Cat One" : ["doc2", "doc3"],
      "Sub Cat Two" : ["doc4", "doc5"]
    },
    "Second Category" : ["doc8"]
  }
}
{
  "docs": {
    "First Category": {
     // Empty key will display no header
      "" : ["doc1"],
      "Sub Cat One" : ["doc2", "doc3"],
      "Sub Cat Two" : ["doc4", "doc5"]
    },
    "Second Category" : ["doc8"]
  }
}

First attempt at implementing this, let me know if some things should be changed. I changed a couple of the functions around to make them easier to write tests against. In the future we could add tests to the rest of the functions in readMetadata.js as well.

Note: We could maybe do some type of accordion for the sub categories if wanted.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit e5228ac

https://deploy-preview-891--docusaurus-preview.netlify.com

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 7, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@yangshun yangshun merged commit 16087b4 into facebook:master Aug 7, 2018
yangshun added a commit that referenced this pull request Aug 7, 2018
@yangshun
Copy link
Contributor

yangshun commented Aug 7, 2018

@WillBrock Sorry I clicked the wrong button. Could you resubmit the PR? Very sorry.

@WillBrock
Copy link
Contributor Author

@yangshun no problem. Added it in #892

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants