Skip to content

Conversation

@psrpinto
Copy link
Member

@psrpinto psrpinto commented Dec 9, 2024

Fixes #134

This PR adds the ./schemas/ directory, but it is not used from anywhere yet.

The schemas can be validated with:

schemas/validate.mjs

Summary of changes

  • Implement a script that validates all schemas under ./schemas/
  • Define the JSON Schema
  • Define the Schema of a blog post
  • Define the Schema of a page
  • Make the validation script ensure that there are no two schemas with the same slug

References

@psrpinto psrpinto self-assigned this Dec 9, 2024
@psrpinto psrpinto changed the title Add schema files and the respective JSON Schema Add JSON Schema and individual schema files Dec 9, 2024
Copy link
Member Author

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

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

#146 does some of the same things as here but in a schema/ directory, while here we're adding to schemas/. I deliberately added it to a different directory than #146, so that we can merge both PRs. Then I can open a new PR that integrates the two.

@psrpinto psrpinto marked this pull request as ready for review December 9, 2024 20:18
@psrpinto psrpinto requested a review from akirk December 9, 2024 20:19
@psrpinto psrpinto requested a review from ashfame December 9, 2024 20:19
Copy link
Member

@ashfame ashfame left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -0,0 +1,15 @@
{
"title": "Blog Post",
"slug": "blog_post",
Copy link
Member

Choose a reason for hiding this comment

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

We decided on SubjectType enum to have dash as opposed to underscore earlier, we should keep both consistent, whatever that is. Personally, I think dash is better in all contexts where we might display it to the user or have it in the url?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should use what's allowed via the custom post types allowed in WordPress: https://developer.wordpress.org/reference/functions/register_post_type/

Post type key. Must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores. See sanitize_key() .

If we say we do 4 letter prefixes this would leave 16 chars of the above and we can do dashes instead of underscores.

Copy link
Member Author

@psrpinto psrpinto Dec 10, 2024

Choose a reason for hiding this comment

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

Ok, I've made it so that dashes are accepted (underscores are not), and I've limited the length to 16 characters. This would mean that the post_type prefix that we use must not exceed 4 characters, for example twp_. If we end up using a longer prefix, we need to reduce the max length accordingly.

Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

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

Looks good! I just added a couple of notes and noticed that we are mixing spaces and tabs indentation, I believe the JSON files can be tab indented as well.

@psrpinto psrpinto requested review from akirk and ashfame December 10, 2024 12:57
Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

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

Great, thank you!

@psrpinto psrpinto merged commit bdef08c into trunk Dec 10, 2024
3 checks passed
@psrpinto psrpinto deleted the schema-files branch December 10, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define the structure of a Schema with a json-schema.org

4 participants