Created
March 5, 2015 16:00
-
-
Save egardner/5a7eaa314c0104235a39 to your computer and use it in GitHub Desktop.
Jekyll JSON template
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: null | |
--- | |
[ | |
{% for post in site.posts %} | |
{ | |
"title" : "{{ post.title }}", | |
"url" : "{{ post.url }}", | |
"date" : "{{ post.date | date: "%B %d, %Y" }}", | |
"content" : "{{ post.content | strip_html | strip_newlines | escape_once }}" | |
} {% if forloop.last %}{% else %},{% endif %} | |
{% endfor %} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This generates valid JSON from Jekyll posts when Jekyll runs.
strip_newlines
is essential in the content field, butstrip_html
is not. To return safe HTML instead of a raw string, do this:"content" : "{{ post.content | strip_newlines | escape }}"