Using git to generate a changelog for your blogEvan Travers
Unrelated, but what did you do to set up the
changelogat the bottom of your posts?
A long time ago, Tom Miller talked about how frustrating it is when you come back to a blog page and there's something... missing or changed. We elaborated into how cool it would be to have a living document for different topics on your blog, instead of posting a new git manifesto every year, just have a URL with the latest copy and all the changes.
I haven't gone all the way that direction yet... I've got a couple private mini-essays I'll link around, but I did implement the following. My blog uses middleman, so every file and every blog post has a git history. I use the Git gem to pull the git commits, and use the simple_format ActionView helper to display it.
<% @git = Git.open('./').log.object(file) if @git.size > 1 %> <details class="blog__changes"> <summary>Changelog</summary> <ul> <% @git.each do |commit| %> <li> <b class="blog__changes__date"><%= commit.author_date %></b> <%= simple_format(commit.message) %> </li> <% end %> </ul> </details> <% end %>
There are some old pages where I don't use good git practices, and it hurts that it shows, but by and large a reader can see what I've changed, whether I added a new company to my EDC bag post, or fixed a typo in a prayer.
I'm pretty sure the basic concept will work with other file-based blog systems... let me know if you use it!
2022-06-08 11:31:29 -0500Rename articles
2020-06-18 14:26:02 -0500Move everything to CST
Don't know why I didn't do that before. It caused _no_ end of
2019-11-14 19:21:38 -0600Remove Tag: programming
`code` is the same tag and has more coverage.
2019-11-08 16:48:11 -0600Turn the `-` bullet into an `—`
2019-11-08 16:47:17 -0600Add final sentence
2019-11-08 16:46:33 -0600New post: git changelog