Skip to content

Instantly share code, notes, and snippets.

@tamouse
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamouse/10a2240570696d81cf5e to your computer and use it in GitHub Desktop.
Save tamouse/10a2240570696d81cf5e to your computer and use it in GitHub Desktop.
jekyll format post as json file exampel
{
"title": "Quote: Control is an Illusion",
"categories": [
"quotes"
],
"tags": [
"control",
"illusion",
"delusion"
],
"date": "2015-07-22 19:27",
"body": "<blockquote>\n <p>Control is an illusion. Giving in to chaos is the only way\nthrough. You don’t surf by telling the waves what to do.</p>\n <footer><a href=\"http://tamouse.org\">tamouse</a></footer>\n</blockquote>\n"
}
---
layout: none
title: "Quote: Control is an Illusion"
date: 2015-07-22 19:27
categories: ["quotes"]
tags: ["control", "illusion", "delusion"]
---
> Control is an illusion. Giving in to chaos is the only way
> through. You don't surf by telling the waves what to do.
> <footer><a href="http://tamouse.org">tamouse</a></footer>
require "json"
Jekyll::Hooks.register :post, :post_render do |post|
# code to call after Jekyll renders a post
json_post = post.data.merge("body" => post.content)
dest = File.join(post.site.dest, File.basename(post.name, ".*")) + ".json"
json = JSON.pretty_generate(json_post)
post.site.keep_files << dest
File.write(dest, json)
end
@tamouse
Copy link
Author

tamouse commented Jul 23, 2015

post.markdown.txt is really just the post.markdown. i didn't want gist to format it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment