Skip to content

Strict frontmatter validation #4591

Closed

Description

@slorber

🚀 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.

Activity

  1. added
    feature
    good first issue
    difficulty: starter
    on Apr 9, 2021
  2. Joshverge commented on Apr 10, 2021

    @Joshverge

    @slorber I'd like to help!

  3. slorber commented on Apr 12, 2021

    @slorber
    CollaboratorAuthor

    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

  4. jakehsiao commented on Apr 15, 2021

    @jakehsiao

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

  5. slorber commented on Apr 16, 2021

    @slorber
    CollaboratorAuthor

    @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.

  6. Joshverge commented on Apr 16, 2021

    @Joshverge

    @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

  7. ywjr commented on Apr 17, 2021

    @ywjr
  8. ywjr commented on Apr 17, 2021

    @ywjr
  9. slorber commented on Apr 19, 2021

    @slorber
    Author
  10. ywjr commented on Apr 19, 2021

    @ywjr

    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

  11. ywjr commented on Apr 19, 2021

    @ywjr

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

  12. slorber commented on Apr 19, 2021

    @slorber
    CollaboratorAuthor

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

  13. ywjr commented on Apr 21, 2021

    @ywjr

    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?

  14. slorber commented on Apr 21, 2021

    @slorber
    CollaboratorAuthor

    @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.

  15. nam-hle commented on May 6, 2021

    @nam-hle
    Contributor

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

  16. ywjr commented on May 6, 2021

    @ywjr
  17. slorber commented on May 6, 2021

    @slorber
    CollaboratorAuthor

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

  18. linked a pull request that will close this issuefeat(v2): exhaustive docs frontmatter schema #4796on May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: starterfeaturegood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions