Adding Last Modified Support to Astro Blog Posts
A quick account of implementing a programmatic solution to modifying dates in blog posts
This morning I set out to update my Personal Blog powered by Astro. In an effort to do more writing, I am trying to make sure the platform that I’m using for said writing is as accommodating as possible. My posts have had a “Last Updated” field for a while and it’s just been the same as the publish date. So I looked into automating the process so that any time I make an update to a post, the “Last Updated” field is programmatically updated. This way I don’t have to trust myself to do it as I’ve proven incredibly unreliable for this task.
Since I took the time to do it, I figured I’d recap the process. To begin, I actually found that Astro includes a “Recipe” for this in their docs. This actually made me super happy because the other solutions that I came across involved pre-commit hooks and shell scripts and a bunch of other config that is definitely interesting and fun. But it’s also a giant pain in the ass when you just want one specific outcome.
I won’t bog down this post with code examples as I pretty much just followed the recipe from Astro. But what is really cool to learn is that I can make my own plugins for the purposes of pre-processing. Being able to programmatically manipulate data like this open up some pretty cool doors because it allows me to let the computer do the jobs that the computer does well and allows me to focus on what I really care about which is building cool shit and writing about it.