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

Write a YAML schema for all the currently supported front matter properties for blog posts #258

Closed
caendesilva opened this issue Jul 22, 2022 · 6 comments · Fixed by #351

Comments

@caendesilva
Copy link
Member

No description provided.

@caendesilva
Copy link
Member Author

caendesilva commented Aug 4, 2022

Had a random thought, what if we could write schemas as traits? That way the properties could be strongly typed and directly enforced. This way they are already semantic, and always up to date compared to documentation. And the front matter when accessed could merge those properties into the matter array at runtime.

For example:

class MarkdownPost
{
    use FrontMatter\BlogPostSchema;
}

@caendesilva
Copy link
Member Author

Forgot the schema is actually documented, so this is gonna be a lot easier https://hydephp.com/docs/master/blog-posts#supported-front-matter-properties

@caendesilva
Copy link
Member Author

Maybe also add a note that the slug/identifier is reserved by Hyde and cannot be overridden by front matter

@caendesilva
Copy link
Member Author

Thinking a bit on how I want to handle these. On one hand, I like the idea of having these traits to only house data like follows (with comments removed for brevity)

trait BlogPostSchema
{
    public string $title;
    public ?string $description = null;
    public ?string $category = null;
    public ?DateString $date = null;
    public ?Author $author = null;
    public ?Image $image = null;
}

But being able to construct and configure the data right there would be nice, at least when developing, so I'll try that.

@caendesilva
Copy link
Member Author

Also want schema for general pages to include the common shared data and any meta tags and opengraph tags. The whole point of this change is to make it clear to users and developers what data is accessible and where it is generated from.

@caendesilva
Copy link
Member Author

Upside is also that it should be easy enough to write a parser that automatically makes changes to the docs based on the actual schema being used (not that that will be an issue later on in v1 as a schema change is probably breaking)

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 a pull request may close this issue.

1 participant