Last active
August 29, 2015 14:25
-
-
Save tamouse/10a2240570696d81cf5e to your computer and use it in GitHub Desktop.
jekyll format post as json file exampel
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
{ | |
"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" | |
} |
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
--- | |
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> |
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 "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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
post.markdown.txt is really just the post.markdown. i didn't want gist to format it...