Created
January 5, 2018 08:10
-
-
Save hrysd/62a4a82575141c409858bc7b41603dbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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