#!/usr/bin/env ruby require 'date' require 'kramdown' require 'erb' abort "Usage: #$0 " if ARGV.empty? Post = Struct.new(:path) do def title Date.strptime(File.basename(path, '.md'), '%Y-%m-%d').strftime('%d %B %Y') end def content Kramdown::Document.new(File.read(path)).to_html end end POSTS_PATH = File.join(ARGV[0], '*.md') POSTS = Dir.glob(POSTS_PATH).sort.reverse.map { |path| Post.new(path) } puts ERB.new(DATA.read).result __END__ ~crm

~crm

<% POSTS.each do |post| %>

<%= post.title %>

<%= post.content %>
<% end %>