mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-19 03:57:01 +02:00
feat: docs plugin options sidebarCollapsible + sidebarCollapsed (#5203)
* Add prop Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Add `collapsible` option to sidebar item Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Add eslint-ignore Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Move new page Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Allow in autogenerated Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Fix tests Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Move config options to plugin-docs Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Make non-collapsible items always expanded Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * docs versioning cli should receive a single options object * Update cli.test.ts * revert validateCategoryMetadataFile change * remove theme usage of themeConfig.sidebarCollapsible * better handling of sidebar item category inconsistencies + add warning message * Update snapshot Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Handle plugin option inconsistencies * improve doc for new sidebarCollapsible doc options * remove warning in fixSidebarItemInconsistencies as it will be annoyed for versioned sites, as "collapsed" is already persisted in sidebar json files Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
b38c35a36d
commit
24156efcfb
27 changed files with 487 additions and 109 deletions
|
@ -82,6 +82,16 @@ module.exports = {
|
|||
* Path to sidebar configuration for showing a list of markdown pages.
|
||||
*/
|
||||
sidebarPath: 'sidebars.js',
|
||||
/**
|
||||
* By default, all sidebar categories will be collapsible.
|
||||
* This can be overriden per-category.
|
||||
*/
|
||||
sidebarCollapsible: true,
|
||||
/**
|
||||
* By default, all sidebar categories will be initialized in a collapsed state.
|
||||
* This can be overriden per-category.
|
||||
*/
|
||||
sidebarCollapsed: false,
|
||||
/**
|
||||
* Function used to replace the sidebar items of type "autogenerated"
|
||||
* by real sidebar items (docs, categories, links...)
|
||||
|
|
|
@ -285,7 +285,8 @@ type SidebarItemCategory = {
|
|||
items: SidebarItem[]; // Array of sidebar items.
|
||||
|
||||
// Category options:
|
||||
collapsed: boolean; // Set the category to be collapsed or open by default
|
||||
collapsible: boolean; // Set the category to be collapsible
|
||||
collapsed: boolean; // Set the category to be initially collapsed or open by default
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -297,6 +298,7 @@ module.exports = {
|
|||
{
|
||||
type: 'category',
|
||||
label: 'Guides',
|
||||
collapsible: true,
|
||||
collapsed: false,
|
||||
items: [
|
||||
'creating-pages',
|
||||
|
@ -332,15 +334,25 @@ module.exports = {
|
|||
|
||||
#### Collapsible categories {#collapsible-categories}
|
||||
|
||||
For sites with a sizable amount of content, we support the option to expand/collapse a category to toggle the display of its contents. Categories are collapsible by default. If you want them to be always expanded, set `themeConfig.sidebarCollapsible` to `false`:
|
||||
By default, categories are collapsible and collapsed.
|
||||
|
||||
The docs plugin options allow to change these defaults globally:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
themeConfig: {
|
||||
// highlight-start
|
||||
sidebarCollapsible: false,
|
||||
// highlight-end
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
docs: {
|
||||
// highlight-start
|
||||
sidebarCollapsible: true,
|
||||
sidebarCollapsed: false,
|
||||
// highlight-end
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -356,6 +368,7 @@ module.exports = {
|
|||
{
|
||||
type: 'category',
|
||||
label: 'Docs',
|
||||
collapsible: true,
|
||||
collapsed: false,
|
||||
items: ['markdown-features', 'sidebar', 'versioning'],
|
||||
},
|
||||
|
@ -465,6 +478,7 @@ This is the easy tutorial!
|
|||
```yaml title="docs/tutorials/_category_.yml"
|
||||
label: 'Tutorial'
|
||||
position: 2.5 # float position is supported
|
||||
collapsible: true # make the category collapsible
|
||||
collapsed: false # keep the category open by default
|
||||
```
|
||||
|
||||
|
|
|
@ -229,8 +229,6 @@ module.exports = {
|
|||
copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc.`, // You can also put own HTML here.
|
||||
},
|
||||
image: 'img/docusaurus.png',
|
||||
// Equivalent to `docsSideNavCollapsible`.
|
||||
sidebarCollapsible: false,
|
||||
// ...
|
||||
},
|
||||
};
|
||||
|
@ -399,7 +397,7 @@ The following fields are all deprecated, you may remove from your configuration
|
|||
- `defaultVersionShown` - Versioning is not ported yet. You'd be unable to migration to Docusaurus 2 if you are using versioning. Stay tuned.
|
||||
- `disableHeaderTitle`
|
||||
- `disableTitleTagline`
|
||||
- `docsSideNavCollapsible` is available at `themeConfig.sidebarCollapsible`, and this is turned on by default now.
|
||||
- `docsSideNavCollapsible` is available at `docsPluginOptions.sidebarCollapsible`, and this is turned on by default now.
|
||||
- `facebookAppId`
|
||||
- `facebookComments`
|
||||
- `facebookPixelId`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue