-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
feat(v2): allow infinitely nested sidebar #1812
Conversation
Deploy preview for docusaurus-2 ready! Built with commit e056ac2 |
Deploy preview for docusaurus-preview ready! Built with commit e056ac2 |
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.
Awesome work! I made some small nitpicky changes. Do we want to consider removing support for the object format and force an array format? Also, we can allow a simpler format for the most common use cases. If a 2nd index is present and it's an array, that item is a category and the values in the 2nd array are children of that category. This definitely makes us have more work to do but is less verbose and resembles the plugins/preset config. WDYT?
module.exports = {
docs: [
[
'item', [
'inner-foo',
'inner-bar',
],
],
]
}
This would be a breaking change but it's one that's worth making IMO.
Merging first, we can talk about new API in future. |
I personally dont mind but from another perspective I think its not a good idea to force array format as it is only a syntatic sugar. There has been many breaking changes already :( Note that there are versioned sidebar as well. Migration will be even more painful (eg: for RN). If we can have less breaking changes thats better const old = {
docs: [
{
type: 'category',
label: 'level 1',
items: [
'introduction',
'contributing',
]
},
{
type: 'category',
label: 'Guides',
items: [
'blog',
]
},
]
};
const new = {
docs: {
'level 1': [
'introduction',
'contributing'
],
'Guides': ['blog']
}
} Both docusaurus/packages/docusaurus-plugin-content-docs-legacy/src/sidebars.ts Lines 90 to 115 in 1591128
|
Motivation
continuation from #1811
Expect more PR on docs plugin probably this week as I try to make docs metadata more efficient later on.
fix #827 #868 #1182
https://deploy-preview-1812--docusaurus-2.netlify.com/docs/sidebar
(We actually already allow external href, etc its just undocumented because i forgot)
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
Try with docu v2 site
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)