Skip to content

Instantly share code, notes, and snippets.

@hrysd
Created January 5, 2018 08:10
Show Gist options
  • Save hrysd/62a4a82575141c409858bc7b41603dbf to your computer and use it in GitHub Desktop.
Save hrysd/62a4a82575141c409858bc7b41603dbf to your computer and use it in GitHub Desktop.
require 'jekyll'
site = Jekyll::Site.new(Jekyll.configuration)
array = Dir.glob('./_posts/*').map {|post|
document = Jekyll::Document.new(post, site: site, collection: Jekyll::Collection.new(site, 'post'))
document.read
{
title: document.data['title'],
slug: document.data['slug'],
body: document.content.gsub(/##/, '###'),
markup: 'redcarpet',
type: 'Post',
draft: false,
created_at: document.date,
updated_at: document.date
}
}
File.open('out.json', 'w') do |f|
f.write JSON.dump(array)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment