Skip to content

Instantly share code, notes, and snippets.

@bmann
Created September 30, 2018 03:23
Show Gist options
  • Save bmann/38b54d893d506d2eb8bb8b325eafaccf to your computer and use it in GitHub Desktop.
Save bmann/38b54d893d506d2eb8bb8b325eafaccf to your computer and use it in GitHub Desktop.
JSON feeds for Jekyll to feed into MicroBlog
---
layout: null
permalink: /feed.json
---
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ site.title | xml_escape }}",
"home_page_url": "{{ site.url }}{{ site.baseurl | absolute_url }}",
"feed_url": "{{ "/feed.json" | absolute_url }}",
"description": {{ site.description | jsonify }},
"icon": "{{ site.icon | absolute_url }}",
"favicon": "{{ "/favicon.ico" | absolute_url }}",
"expired": false,
"items": [
{% assign postCounter = 0 %}
{% assign maxPosts = 15 %}
{% for post in site.posts %}
{% unless post.categories contains "social" %}
{% assign postCounter = postCounter | plus: 1 %}
{% capture content_text %}{{ post.content | strip_html }}{% endcapture %}
{% capture content_html %}{{ post.content | markdownify }}{% endcapture %}
{
"id": "{{ post.url | absolute_url | sha1 }}",
{% if post.title != "" %}"title": {{ post.title | jsonify }},{% endif %}
"content_text": {{ content_text | jsonify }},
"content_html": {{ content_html | jsonify }},
"url": "{{ post.url | absolute_url}}",
"date_published": "{{ post.date | date_to_xmlschema }}",
{% if post.modified %}"date_modified": "{{ post.modified | date_to_xmlschema }}",{% endif %}
"author": {
"name": "{{ site.author.name }}"
}
}{% if postCounter < maxPosts %},{% else %}{% break %}{% endif %}
{% endunless %}
{% endfor %}
]
}
---
layout: null
permalink: /micro.json
---
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ site.title | xml_escape }}",
"home_page_url": "{{ site.url }}{{ site.baseurl | absolute_url }}",
"feed_url": "{{ "/micro.json" | absolute_url }}",
"description": {{ site.description | jsonify }},
"icon": "{{ site.icon | absolute_url }}",
"favicon": "{{ "/favicon.ico" | absolute_url }}",
"expired": false,
"items": [
{% for post in site.categories["social"] limit: 15 %}
{% capture content_text %}{{ post.content | strip_html }}{% endcapture %}
{% capture content_html %}{{ post.content | markdownify }}{% endcapture %}
{
"id": "{{ post.url | absolute_url | sha1 }}",
"content_text": {{ content_text | jsonify }},
"content_html": {{ content_html | jsonify }},
"url": "{{ post.url | absolute_url}}",
"date_published": "{{ post.date | date_to_xmlschema }}",
{% if post.modified %}"date_modified": "{{ post.modified | date_to_xmlschema }}",{% endif %}
"author": {
"name": "{{ site.author.name }}"
}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment