-
-
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): exhaustive docs frontmatter schema #4796
Conversation
[V2] Built without sensitive environment variables with commit f632a6f |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4796--docusaurus-2.netlify.app/ |
9cf4c73
to
f632a6f
Compare
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, that looks great 👍
description: Joi.string().allow(''), // see https://github.com/facebook/docusaurus/issues/4591#issuecomment-822372398 | ||
slug: Joi.string(), | ||
sidebar_label: Joi.string(), | ||
sidebar_position: Joi.number(), | ||
custom_edit_url: Joi.string().allow('', null), | ||
sidebar_position: Joi.number().min(0), |
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.
I don't think this is technically required and negative values would also work, but it would probably not harm to forbid this
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.
Motivation
The continuation of #4591.
Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
Unit test.
Related PRs
#4759.