diff --git a/docs/api-site-config.md b/docs/api-site-config.md index fe18a7ceac..5c1e0834e7 100644 --- a/docs/api-site-config.md +++ b/docs/api-site-config.md @@ -139,6 +139,10 @@ An option to disable showing the title in the header next to the header icon. Ex An option to disable showing the tagline in the title of main pages. Exclude this field to keep page titles as `Title • Tagline`. Set to `true` to make page titles just `Title`. +#### `docsSideNavCollapsible` [boolean] + +Set this to `true` if you want to be able to expand/collapse the links and subcategories in the sidebar. + #### `editUrl` [string] URL for editing docs, usage example: `editUrl + 'en/doc1.md'`. If this field is omitted, there will be no "Edit this Doc" button for each document. diff --git a/docs/guides-navigation.md b/docs/guides-navigation.md index ff8f2e3199..d35b9b25fa 100644 --- a/docs/guides-navigation.md +++ b/docs/guides-navigation.md @@ -272,3 +272,14 @@ We support secondary on-page navigation so you can more easily see the topics as ``` Currently, `'separate'` is the only option available for this field. This provides a separate navigation on the right side of the page. + +## Collapsible Categories + +For sites with a sizable amount of content, we support the option to expand/collapse the links and subcategories under categories. To enable this feature, set the `docsSideNavCollapsible` site configuration [option](api-site-config.md#optional-fields) in `siteConfig.js` to true. + +```js +{ + docsSideNavCollapsible: true, + ... +} +``` diff --git a/v1/lib/core/nav/SideNav.js b/v1/lib/core/nav/SideNav.js index cfe83e8055..21cdb75597 100644 --- a/v1/lib/core/nav/SideNav.js +++ b/v1/lib/core/nav/SideNav.js @@ -61,25 +61,38 @@ class SideNav extends React.Component { return null; } - renderCategory = categoryItem => ( -