Skip to content

fix(v2): allow negative sidebar positions#5074

Merged
slorber merged 1 commit intofacebook:masterfrom
kdrag0n:negative-sidebar-position
Jun 28, 2021
Merged

fix(v2): allow negative sidebar positions#5074
slorber merged 1 commit intofacebook:masterfrom
kdrag0n:negative-sidebar-position

Conversation

@kdrag0n
Copy link
Contributor

@kdrag0n kdrag0n commented Jun 28, 2021

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.

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.
@kdrag0n kdrag0n requested review from lex111 and slorber as code owners June 28, 2021 08:15
@facebook-github-bot
Copy link
Contributor

Hi @kdrag0n!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions
Copy link

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 71
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5074--docusaurus-2.netlify.app/

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 28, 2021
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Jun 28, 2021
@slorber
Copy link
Collaborator

slorber commented Jun 28, 2021

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 docs-1.5-Guide.md), not sure it's worth adding that until someone come with a need

@slorber slorber merged commit 79031af into facebook:master Jun 28, 2021
@kdrag0n kdrag0n deleted the negative-sidebar-position branch June 28, 2021 19:08
kdrag0n added a commit to kdrag0n/protonaosp.kdrag0n.dev that referenced this pull request Jul 10, 2021
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants