-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Allow some sidebars to be collapsible, but others not. #2927
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 9ce121b |
There was a problem hiding this 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'], |
There was a problem hiding this comment.
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?
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 |
🤦 I should have looked at recent additions. Looks like #2682 took care of this. |
ah yeah ^^ already forgot that feature 🤦 |
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 needthemeConfig.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 likethemeConfig.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 thedocs
sidebar was still collapsible, but thecommunity
sidebar wasn't. I then addedthemeConfig.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