hyde icon indicating copy to clipboard operation
hyde copied to clipboard

Image front matter in pages

Open LBreda opened this issue 11 months ago • 6 comments

Hi,

Why is the "image" front matter variable ignored in simple pages? The og:image metadata is very useful for "articles" too!

LBreda avatar Feb 27 '25 20:02 LBreda

Hey! That's a great question! The technical answer is that the image front matter property is just part of the blog post schema. The real answer is simply that I haven't thought about it! But that's for sure something we should have so let's add this to the backlog!

In the meantime, I would recommend that you publish the base Markdown page template (or whichever type you want to use this for) and implement this in your project as this can still be done in userland while we wait for this to be implemented. Feel free to make a PR to the v2 branch if you want of course! Thanks again for suggesting this! 🙌

emmadesilva avatar Feb 28 '25 10:02 emmadesilva

this can still be done in userland

How? Is it possible to read data from the front matter in the templates? Thanks!

LBreda avatar Feb 28 '25 11:02 LBreda

this can still be done in userland

How? Is it possible to read data from the front matter in the templates? Thanks!

Yes! This is really easy, from Blade templates you always have access to the global $page variable (which you can also @dd()) and from there you can use $page->matter('key') to access any arbitrary front matter data!

emmadesilva avatar Feb 28 '25 13:02 emmadesilva

Can be implemented similarly to https://github.com/hydephp/develop/pull/1884

emmadesilva avatar May 28 '25 19:05 emmadesilva

I'm applying to address the issue where the image front matter variable is currently ignored in simple pages, even though it's valuable for Open Graph metadata like og:image. Why I'm a Great Fit I write clean, maintainable code and back changes with thoughtful testing and documentation. I’d be excited to bring this improvement to your project and help make simple pages as rich and sharable as articles.

Kidad3grt avatar May 29 '25 23:05 Kidad3grt

Amazing @Kidad3grt! I've assigned you to this task so you can get right on working on this whenever it suits you. Here are the Contribution Guidelines which contain important practical information on how to set up the hydephp/develop where you'll submit your pull request.

When you're ready for your submission to be reviewed, please change your PR from "draft" to "ready for review" and request a review from me. Remember to add tests!

Let me know if you have any questions, and have an amazing time with HydePHP! 🥳

emmadesilva avatar May 30 '25 07:05 emmadesilva