-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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(v2): fix too strict markdown frontmatter validation #4654
Conversation
[V2] Built with commit fbfa345 |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4654--docusaurus-2.netlify.app/ |
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 @johnnyreilly , I see the problem
I'd like to do a small bugfix release soon, and have a few issues reported regarding this frontmatter validation.
As this is likely to create conflicts (like with #4655), I'll take your PR as a base and complete it so that I can release the fix asap!
I changed the assertion to actually return the value. I will try to see if I can convert to number from there
[V1] Built with commit fbfa345 |
Motivation
PR completed by @slorber:
Original description:
To either get a meaningful error message when invalid tags are supplied, or allow them to be parsed successfully (numbers are not) - this relates to #4642
Hey @slorber,
I've started work on this and have some questions. Whilst I can get meaningful error messages using the mechanism you suggest (see changes in
blogFrontMatter.ts
) the suggested:does not seem to support parsing numbers to strings automatically as suggested. Also, even if it did, it won't actually change the type of the tags in the
frontMatter
object. It's just an assertion - no mutation takes place. We could put something in themarkdownParser
here:https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-utils/src/markdownParser.ts#L68-L79
that migrates numbers to strings.... Or alternatively, maybe it just throwing a meaningful error message is fine. I think the meaningful error message is the most significant thing from my perspective.
What do you think?
Have you read the [Contributing Guidelines on pull requests]
Yes
Test Plan
Automated tests!
Related PRs
N/A