summaryrefslogtreecommitdiffstats
path: root/import-blog.rb
blob: 0b9946bdf94e8abad9e6fc0685e29dc338ead8d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env ruby

require 'json'

json = JSON.parse STDIN.read

json['collections'][0]['posts'].each do |post|
  slug = post['slug']
  title = post['title']
  body = post['body']
  f = File.open("blog/#{slug}.md", "w")
  f.write "# #{title}\n"
  f.write "\n"
  f.write body
  f.flush
end