Skip to content
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

Merged
merged 1 commit into from
May 18, 2021

Conversation

nam-hle
Copy link
Contributor

@nam-hle nam-hle commented May 15, 2021

Motivation

The continuation of #4591.

Have you read the Contributing Guidelines on pull requests?

Yes.

Test Plan

Unit test.

Related PRs

#4759.

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 15, 2021
@netlify
Copy link

netlify bot commented May 15, 2021

@github-actions
Copy link

github-actions bot commented May 15, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 51
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

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

@nam-hle nam-hle force-pushed the exhaustive_docs_frontmatter branch from 9cf4c73 to f632a6f Compare May 18, 2021 09:01
Copy link
Collaborator

@slorber slorber left a 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),
Copy link
Collaborator

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

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label May 18, 2021
@slorber slorber linked an issue May 18, 2021 that may be closed by this pull request
@slorber slorber merged commit fa7aa08 into facebook:master May 18, 2021
@nam-hle nam-hle deleted the exhaustive_docs_frontmatter branch May 18, 2021 14:17
slorber pushed a commit that referenced this pull request Jun 28, 2021
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.
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: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strict frontmatter validation
3 participants