Cedric Fung

Mixin me 25566

Jekyll My Blog

Aug 24, 2014

Just migrated my blog to Jekyll, it was a custom Rails application, and I wrote a simple Ruby script to convert all Markdown text in the MongoDB to Jekyll posts.

Post.published.each do |post|
  name = "#{post.created_at.strftime("%Y-%m-%d")}-#{post.slug}.markdown"
  File.open("_posts/#{name}", "w") do |f|
    f.puts "---"
    f.puts "layout: post"
    f.puts "title: \"#{post.title}\""
    f.puts "date:   #{post.created_at.strftime("%Y-%m-%d %H:%M:%S")}"
    f.puts "---"
    f.puts "\n"
    f.puts post.content.gsub("\r\n", "\n").gsub("```shell", "```bash")

With the experience in the heavy Rails framework, it has been much easier for me to use the gems jekyll-assets, autoprefixer-rails and jekyll-sitemap. The Jekyll theme is highly inspired by http://rickharrison.me.


About the Author

Core developer of Mixin Network. Passionate about security and privacy. Strive to formulate elegant code, simple design and friendly machine.

25566 @ Mixin Messenger