Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow some sidebars to be collapsible, but others not. #2927

Conversation

taylorreece
Copy link
Contributor

Motivation

My docs site has several sidebars like https://prismatic.io/docs/getting-started/setting-up that look look best with themeConfig.sidebarCollapsible=false, but other sidebars have gotten rather long, like https://prismatic.io/docs/api/api-overview, and are in need themeConfig.sidebarCollapsible=true. As of right now that option is all-or-nothing.

I'd like the ability to say "by default, I'd like themeConfig.sidebarCollapsible=false, but for these two sidebars I'd like themeConfig.sidebarCollapsible=true".

This commit allows a user to override themeConfig.sidebarCollapsible for a defined list of sidebars.

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

I tested this by updating the "community" sidebar to have some headers, and then setting sidebarCollapsibleOverrides: ['community'],. I verified that the docs sidebar was still collapsible, but the community sidebar wasn't. I then added themeConfig.sidebarCollapsible=false and verified that the inverse was true about the two sidebars.

I also removed both configuration values and verified that docs looked as they did previously, so this doesn't introduce any regressions.

Related PRs

N/A

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 12, 2020
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit 9ce121b

https://deploy-preview-2927--docusaurus-2.netlify.app

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful option, but not fan of sidebarCollapsibleOverrides. I'd rather have a collapsible: false on the sidebar category object

// ...
themeConfig: {
sidebarCollapsible: false,
sidebarCollapsibleOverrides: ['secondSidebar'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of having this sidebarCollapsibleOverrides config

What about declaring the overrides directly in the sidebar file instead?

@slorber
Copy link
Collaborator

slorber commented Jun 15, 2020

What do you think of:

module.exports = {
  firstSidebar: [
    {
      type: 'category',
      collapsible: false,
      label: 'Getting Started',
      items: ['greeting'],
    },
    {
      type: 'category',
      collapsible: false,
      label: 'Docusaurus',
      items: ['doc1'],
    },
  ],
  secondSidebar: [
    {
      type: 'category',
      collapsible: true,
      label: 'Getting Started',
      items: ['greeting'],
    },
    {
      type: 'category',
      collapsible: true,
      label: 'Docusaurus',
      items: ['doc1'],
    },
  ],
};

That would be flexible (category level), and solve your usecase

@taylorreece
Copy link
Contributor Author

🤦 I should have looked at recent additions. Looks like #2682 took care of this.

@slorber
Copy link
Collaborator

slorber commented Jun 15, 2020

ah yeah ^^ already forgot that feature 🤦

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