In this episode, we take a big step forward with our blog by enhancing how we manage and display post details. Previously, our posts were a bit bare, showing just the basic info. To fix that, we dig into the config and switch our content parser over to the "markdown with front matter" parser. This allows us to use YAML front matter at the top of our markdown files, giving us a ton of flexibility to include custom attributes like title
, author
, teaser
, and more.
We walk through editing some sample blog posts, adding a bunch of useful info in the front matter section for each one. This includes setting up the title, author, teaser/summary, and later on we'll add tags. We also touch on the importance of keeping your front matter consistent, since there isn't a strict schema like in a database — you'll want to make sure every post includes the same keys.
Once that's set up, we update our template to output these new attributes, displaying things like the title, teaser, and author right in the post listing. We even jazz it up by formatting and displaying the post date using Carbon methods, showing off options like toDateString()
and diffForHumans()
for user-friendly date formats.
By the end, our blog posts are much richer, and we have the flexibility to add any new attributes we need in the future. It's a simple change, but it really opens up a lot of possibilities for organizing and displaying your blog content.