fix(v2): allow negative sidebar positions#5074
fix(v2): allow negative sidebar positions#5074slorber merged 1 commit intofacebook:masterfrom kdrag0n:negative-sidebar-position
Conversation
In some cases, negative sidebar positions can be useful for reversing the sorting order with minimal maintenance overhead. For example, a docs folder with changelogs for historical versions should be sorted in reverse chronological order. This is easy to do for semantic version numbers by converting them into a negative numerical representation, e.g. 11.5.1 -> -110501. The alternative is to make the first version start with a large position number (e.g. 9999) and decrement it for each version. However, this requires referring to older versions to get the current sequence number, thus increasing maintenance overhead. It also makes the number less intuitive and more prone to error. Negative sidebar positions work great for this purpose, so make the front matter validator allow them again as #4796 broke this use case.
|
Hi @kdrag0n! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
✔️ [V2] 🔨 Explore the source changes: 1ee35b9 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60d985198502330007e901b0 😎 Browse the preview: https://deploy-preview-5074--docusaurus-2.netlify.app |
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5074--docusaurus-2.netlify.app/ |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
Makes sense thanks Thought about it and wasn't sure people would use this 😅 Also note we don't currently have support for extracting negative and float position from the filename (ie |
This reverts commit d2b7a98. This is no longer necessary now that [1] has been merged and we've updated to the canary version. [1] facebook/docusaurus#5074 Signed-off-by: Danny Lin <[email protected]>
Motivation
In some cases, negative sidebar positions can be useful for reversing the sorting order with minimal maintenance overhead. For example, a docs folder with changelogs for historical versions should be sorted in reverse chronological order. This is easy to do for semantic version numbers by converting them into a negative numerical representation, e.g. 11.5.1 -> -110501.
The alternative is to make the first version start with a large position number (e.g. 9999) and decrement it for each version. However, this requires referring to older versions to get the current sequence number, thus increasing maintenance overhead. It also makes the number less intuitive and more prone to error.
Negative sidebar positions work great for this purpose, so make the front matter validator allow them again as #4796 broke this use case.
Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
Negative sidebar positions worked on 2.0.0-beta.0, so I simply reverted #4796 by removing
.min(0). I also added tests that follow the existing format in order to prevent regressions.