Skip to content

Instantly share code, notes, and snippets.

@sjmulder
Created May 22, 2012 12:40
Show Gist options
  • Save sjmulder/2768809 to your computer and use it in GitHub Desktop.
Save sjmulder/2768809 to your computer and use it in GitHub Desktop.
My 12 line “publishing platform”
Dir.glob 'articles/*.md' do |path|
content = File.read(path)
slug = File.basename(path, ".md")
matches = /^# (.*)$/.match(content)
title = matches && matches[1] || slug
get "/articles/#{slug}" do
erb :article, :locals => {
:title => title,
:content => markdown(content)
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment