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

Change internal page data structure to use new front matter schema traits #351

Merged
merged 68 commits into from
Aug 6, 2022

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented Aug 5, 2022

This PR adds schemas as described in #258. These schemas define the public facing data shared to the views, intended to be used by the page templates. For example metadata and SEO information.

The schemas are defined using PHP traits, that also hold the actual data, and may also construct them.

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;
}

class MarkdownPost
{
    use FrontMatter\BlogPostSchema;
}

Another benefit of this is that we are also less reliant on magic methods and properties. Those offered through the front matter object would only really be needed for ad-hoc data added by the user.

There are more schemas to add than what will be added in this PR. Such as documentation pages and image objects. Everything that can be supplied as front matter should be covered.

@caendesilva caendesilva changed the title Add front matter schemas Change internal page data structure to use new front matter schema traits Aug 6, 2022
@caendesilva caendesilva marked this pull request as ready for review August 6, 2022 11:15
@caendesilva caendesilva merged commit 25f4830 into master Aug 6, 2022
@caendesilva caendesilva deleted the front-matter-schemas branch August 6, 2022 11:28
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.

Write a YAML schema for all the currently supported front matter properties for blog posts
2 participants