Skip to content

Commit

Permalink
Allow some sidebars to be collapsible, but others not.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorreece committed Jun 12, 2020
1 parent 729b3ca commit 9ce121b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/docusaurus-theme-classic/src/theme/DocPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function DocPage(props) {
: permalinkToSidebar[currentRoute.path];
const {
siteConfig: {themeConfig: {sidebarCollapsible = true} = {}} = {},
siteConfig: {
themeConfig: {sidebarCollapsibleOverrides = []},
},
isClient,
} = useDocusaurusContext();

Expand All @@ -61,7 +64,11 @@ function DocPage(props) {
docsSidebars={docsSidebars}
path={isHomePage ? homePagePath : currentRoute.path}
sidebar={sidebar}
sidebarCollapsible={sidebarCollapsible}
sidebarCollapsible={
sidebarCollapsibleOverrides.includes(sidebar)
? !sidebarCollapsible
: sidebarCollapsible
}
/>
</div>
)}
Expand Down
15 changes: 15 additions & 0 deletions website/docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,21 @@ module.exports = {
};
```

#### Overriding themeConfig.sidebarCollapsible on some sidebars

If you have multiple sidebars, and would like to collapse some but not others, you can override the `themeConfig.sidebarCollapsible` behavior on a per-sidebar basis. Set `themeConfig.sidebarCollapsibleOverrides` to a list of names of sidebars that should behave the opposite of what you have `themeConfig.sidebarCollapsible` set to.

```js {5} title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
sidebarCollapsible: false,
sidebarCollapsibleOverrides: ['secondSidebar'],
// ...
},
};
```

#### Expanded categories by default

For docs that have collapsible categories, you may want more fine-grain control over certain categories. If you want specific categories to be always expanded, you can set `collapsed` to `false`:
Expand Down

0 comments on commit 9ce121b

Please sign in to comment.