Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save corey/171331 to your computer and use it in GitHub Desktop.
Save corey/171331 to your computer and use it in GitHub Desktop.
articles = Article.find(:all)
articles.each do |article|
published_at = "#{published_at.year}-#{published_at.month}-#{published_at.day}"
author = article.user.login
permalink = article.permalink
title = article.title
excerpt = article.excerpt
body = article.body
fp = File.open("_posts/#{'draft-' if article.published_at.nil?}#{published_at}-#{permalink}.markdown", 'w')
fp.write(%"---
layout: post
title: \"#{title}\"
author: #{author}
---
#{excerpt}
#{body}")
fp.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment