-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
fix: add docs tag validation to solve #5478 #5479
Conversation
fix: add docs tag validation to solve facebook#5478
tags: [Joi.string(), Joi.array().items(Joi.object({ | ||
label: Joi.string, | ||
permalink: Joi.string | ||
}))] |
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.
tags: [Joi.string(), Joi.array().items(Joi.object({ | |
label: Joi.string, | |
permalink: Joi.string | |
}))] | |
tags: Joi.array().items(Joi.alternatives().try( | |
Joi.string(), | |
Joi.object({ | |
label: Joi.string().required(), | |
permalink: Joi.string().required(), | |
}), | |
)), |
Joi is really a pain, yeah
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.
Actually, there's a FrontMatterTagsSchema
from utils-validation
. See here:
import { | |
JoiFrontMatter as Joi, // Custom instance for frontmatter | |
URISchema, | |
validateFrontMatter, | |
FrontMatterTagsSchema, | |
} from '@docusaurus/utils-validation'; |
tags: FrontMatterTagsSchema, |
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.
thank you!
Also, maybe we can elaborate in the documentation? After some pondering I think it's worth documenting both possibilities to avoid confusion. |
added! |
✔️ [V2] 🔨 Explore the source changes: 07cc898 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/6131db85383ece000808ec17 😎 Browse the preview: https://deploy-preview-5479--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5479--docusaurus-2.netlify.app/ |
✔️ [V2] 🔨 Explore the source changes: 8166cac 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/6132038502ac780007994f1e 😎 Browse the preview: https://deploy-preview-5479--docusaurus-2.netlify.app |
Thanks, I'll edit it a bit before merge because Joi default messages are so bad in this case :) |
fix: add docs tag validation to solve #5478
Motivation
nicer developer experience when people put in malformed tags, as suggested by @Josh-Cena #5478 (comment)
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
i confess i did not test this one locally. hoping its a simple one.