Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env ruby
require 'kramdown'
require 'date'
source = ARGV[0]
destination = ARGV[1]
Dir.chdir(source) do |dir|
@posts = []
Dir.glob("20*.md") do |md_file|
post =
html_file = File.basename(md_file, '.md') + '.html'[destination, html_file]), 'w+') do |f|
date = md_file[0,10]
@title = md_file[11..-4].gsub('-', ' ')
@posts << { :title => @title, :slug => html_file, :date => date }
@content =
f.write[source, 'layout.html.erb']))).result(binding)
end[destination, 'index.html']), 'w+') do |f|
f.write[source, 'archive.html.erb']))).result(binding)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment