-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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 nested sidebar category shorthand syntax #2444
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 75ac6ee |
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.
Thanks for this PR @slorber! I really appreciate your efforts especially when this PR is so well-written. Unfortunately using objects for the sidebar is really bad design on v1's part due to the implicit relying of object keys order. The only reason we kept it in v2 is to maintain compatibility with v1. I might even want to kill allowing the object syntax entirely in v2, so we don't want to further encourage such syntax.
Any thoughts?
Hi and thanks for the review. I don't know if this should be added or not, so I let you decide. To me the syntax looks convenient and safe, as long as it's documented that the object keys should be declared in correct order. Afaik the order of keys is predictable in Node (didn't check Deno) and seems specified in ES6. |
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.
Much thanks!
@@ -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. |
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.
will try to find a better text for this, as it seems specified in ES6
Motivation
The sidebar category shorthand syntax only works for the 1st level (for example
Guides
).I think it makes sense to generalize this syntax and allow it for deeply nested categories as well
can be shortened as
Have you read the Contributing Guidelines on pull requests?
YES
Test Plan
Jest tests written
Related PRs
N/A