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

Strict frontmatter validation #4591

Closed
slorber opened this issue Apr 9, 2021 · 17 comments · Fixed by #4796
Closed

Strict frontmatter validation #4591

slorber opened this issue Apr 9, 2021 · 17 comments · Fixed by #4796
Labels
difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR.

Comments

@slorber
Copy link
Collaborator

slorber commented Apr 9, 2021

🚀 Feature

We should validate docs/blog/pages frontmatter against a Joi schema:

  • prevent the user to use bad frontmatter
  • display friendly error messages when this happens
  • allow unknown frontmatter (user can assign additional metadata to each doc)
  • unit-test this validation logic
  • try to use the frontmatter TS types in the theme?

Some initial work has been done in #4590 for Docs and Blog, but is not exhaustive as it was not really the point of this PR.

Asking for help from the community to get this work completed in a more exhaustive and polished way.

Please claim this issue if you are willing to help.

@slorber slorber added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. help wanted Asking for outside help and/or contributions to this particular issue or PR. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. labels Apr 9, 2021
@ChayceJRoss
Copy link

ChayceJRoss commented Apr 9, 2021

I'd be willing to help with this.
Is the union of these - https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs#markdown-frontmatter and https://docusaurus.io/docs/blog#header-options a full list of frontmatter options?

@Joshverge
Copy link

@slorber I'd like to help!

@slorber
Copy link
Collaborator Author

slorber commented Apr 12, 2021

As we have 2 volunteers, I suggest:

  • @ChayceJRoss works on docs: packages/docusaurus-plugin-content-docs/src/docFrontMatter.ts
  • @Joshverge works on blog: packages/docusaurus-plugin-content-blog/src/blogFrontMatter.ts

Can you please review each-others and make sure both PRs have some kind of consistency and similar test structure?

Yes @ChayceJRoss those are the exhaustive list of frontmatter options to support

@jakehsiao
Copy link

I'd like to help too, where I can grab?

@slorber
Copy link
Collaborator Author

slorber commented Apr 16, 2021

@jakehsiao we can't split more the work than it is already.
If we don't have news from @ChayceJRoss and @Joshverge under 7 days we'll assign that to you.

@Joshverge
Copy link

@slorber maybe @jakehsiao could grab the work assigned to me? I haven't been able to make much progress since I'm a beginner at ts/js

@ywjr

This comment has been minimized.

@ywjr

This comment has been minimized.

@slorber

This comment has been minimized.

@ywjr
Copy link

ywjr commented Apr 19, 2021

After testing again, the title in the MD file cannot be empty. If it is empty, an error will appear.

In addition, when the title field in the MD file is Chinese, there is no problem

@ywjr
Copy link

ywjr commented Apr 19, 2021

I don't think it's a bug, but it's suggested to give which document's title is empty. Thank you

@slorber
Copy link
Collaborator Author

slorber commented Apr 19, 2021

Ah I see, so you had something like title: right?
What was your motivation to have an empty title like that?

@ywjr
Copy link

ywjr commented Apr 21, 2021

yes ,like title: , when i write md doc file in Chinese, i think ​the font size of the title is too large on md doc page , but I can't change it, so i make title empty 。the font size of the title, H1, H2, H3, etc. can be modified by the user?

@slorber
Copy link
Collaborator Author

slorber commented Apr 21, 2021

@ywjr let's track the too strict validation of title/description here #4652

You can definitively change the default style/font-size of the title through many ways: custom css, swizzling, providing a MDX h1 component... all these are documented.

@nam-hle
Copy link
Contributor

nam-hle commented May 6, 2021

I see two our assignees can't arrange enough time to work. Can I take some job here? 😁

@ywjr
Copy link

ywjr commented May 6, 2021 via email

@slorber
Copy link
Collaborator Author

slorber commented May 6, 2021

please go ahead @nam-hle , as others didn't make any progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants