Skip to content

feat(v2): exhaustive docs frontmatter schema - #4796

Merged
slorber merged 1 commit into
meta:masterfrom
nam-hle:exhaustive_docs_frontmatter
May 18, 2021
Merged

slorber merged 1 commit into
meta:masterfrom
nam-hle:exhaustive_docs_frontmatter

Conversation

@nam-hle

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

Copy link
Copy Markdown
Contributor

Motivation

The continuation of #4591.

Have you read the Contributing Guidelines on pull requests?

Yes.

Test Plan

Unit test.

Related PRs

#4759.

@nam-hle
nam-hle requested review from lex111 and slorber as code owners May 15, 2021 02:31
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 15, 2021
@netlify

netlify Bot commented May 15, 2021 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 15, 2021 •

Copy link
Copy Markdown

⚡️ 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

@slorber slorber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that looks great 👍

sidebar_label: Joi.string(),
sidebar_position: Joi.number(),
custom_edit_url: Joi.string().allow('', null),
sidebar_position: Joi.number().min(0),

Copy link
Copy Markdown
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 meta: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.
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
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 meta#4796 broke this use case.
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
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

4 participants