mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
feat(v2): allow nested sidebar category shorthand syntax (#2444)
* feat(v2): allow sidebar category shorthand syntax also for nested elements * Update sidebars-category-shorthand.js * Update sidebars-category-shorthand.js Co-authored-by: Yangshun Tay <tay.yang.shun@gmail.com>
This commit is contained in:
parent
85c124e3f1
commit
201c663318
12 changed files with 116 additions and 52 deletions
|
@ -50,7 +50,7 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
If you don't want to rely on iteration order of JavaScript object keys for the category name, the following sidebar object is also equivalent of the above.
|
||||
Keep in mind that EcmaScript does not guarantee `Object.keys({a,b}) === ['a','b']` (yet, this is generally true). If you don't want to rely on iteration order of JavaScript object keys for the category name, the following sidebar object is also equivalent of the above shorthand syntax.
|
||||
|
||||
```js
|
||||
// sidebars.js
|
||||
|
@ -221,7 +221,23 @@ module.exports = {
|
|||
{
|
||||
type: 'category',
|
||||
label: 'Docs',
|
||||
items: ['markdown-features', 'sidebar'],
|
||||
items: ['markdown-features', 'sidebar', 'versioning'],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
**Note**: it's possible to use the shorthand syntax to create nested categories:
|
||||
|
||||
```js
|
||||
// sidebars.js
|
||||
module.exports = {
|
||||
docs: {
|
||||
Guides: [
|
||||
'creating-pages',
|
||||
{
|
||||
Docs: ['markdown-features', 'sidebar', 'versioning'],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -19,9 +19,7 @@ module.exports = {
|
|||
'styling-layout',
|
||||
'static-assets',
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Docs',
|
||||
items: ['markdown-features', 'sidebar', 'versioning'],
|
||||
Docs: ['markdown-features', 'sidebar', 'versioning'],
|
||||
},
|
||||
'blog',
|
||||
'search',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue