The other side of the newspaper clipping

Published by Beto Dealmeida on

Showing a random news headline with each of my blog posts

One day, while looking at old newspaper clippings with my dad, he told me:

The other side of the clipping is always more interesting than the clipping itself!

And while "always" was a bit of stretch, it was often true. It was fun turning the clipping around and reading the half-news that were captured by accident.

I decided to do something similar with my blog. My static generator has an "assistant" that fetches the current weather when I create a new post (even though it's currently not displayed anywhere). I used it as a template to write another "assistant" that fetches a random headline of the day, and stores it in a file called news.yaml.

Later, I can then incorporate this in my templates. The static generator loads all YAML files that live alongside a post (like news.yaml, or current_weather.yaml), and exposes them to the templates, eg:

Current weather: {{ post.metadata.current_weather.current_condition.weatherDesc.value }}

In this day: "{{ }}"

For now, I'm just happy in keeping these headlines saved.

Edit: I've decided to only show the headlines when the post is older than 1 year.