From ad182cf2b78dc65c18ea53215f64263e8c0026ea Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Sun, 14 Jul 2019 18:42:07 -0400 Subject: [PATCH] Add everything feed --- _includes/head.html | 4 +++ feed.blog.json | 66 +++++++++++++++++++++++++++++++++++++++++++++ feed.blog.xml | 27 +++++++++++++++++++ feed.json | 2 +- feed.xml | 2 +- 5 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 feed.blog.json create mode 100644 feed.blog.xml diff --git a/_includes/head.html b/_includes/head.html index 632809c..2ae6ddd 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -12,6 +12,10 @@ + + + + diff --git a/feed.blog.json b/feed.blog.json new file mode 100644 index 0000000..1116e09 --- /dev/null +++ b/feed.blog.json @@ -0,0 +1,66 @@ +--- +layout: +--- + +{ + "version": "https://jsonfeed.org/version/1", + {% if site.title %} + "title": {{ site.title | smartify | jsonify }}, + {% elsif site.name %} + "title": {{ site.name | smartify | jsonify }}, + {% endif %} + {% if site.description %} + "description": {{ site.description | jsonify }}, + {% endif %} + "home_page_url": {{ '/' | absolute_url | jsonify }}, + "feed_url": {{ page.url | absolute_url | jsonify }}, + {% if site.author %} + "author": { + "name": {{ site.author.name | default: site.author | jsonify }} + {% if site.author.uri %} + , "url": {{ site.author.uri | jsonify }} + {% endif %} + {% if site.author.avatar %} + , "avatar": {{ site.author.avatar | jsonify }} + {% endif %} + }, + {% endif %} + "items": [ + {% assign posts = site.posts | where_exp: "post", "post.draft != true" | where_exp: "post", "post.categories contains 'blog'" %} + {% for post in posts limit: 20 %} + { + "id": {{ post.id | absolute_url | jsonify }}, + "url": {{ post.url | absolute_url | jsonify }}, + "title": {{ post.title | smartify | strip_html | normalize_whitespace | jsonify }}, + "content_html": {{ post.content | strip | jsonify }}, + {% if post.excerpt and post.excerpt != empty %} + "summary": {{ post.excerpt | strip_html | normalize_whitespace | jsonify }}, + {% endif %} + {% assign post_image = post.image.path | default: post.image %} + {% if post_image %} + {% unless post_image contains "://" %} + {% assign post_image = post_image | absolute_url | xml_escape %} + {% endunless %} + "image": {{ post_image | jsonify }}, + {% endif %} + {% assign post_banner_image = post.banner_image.path | default: post.banner_image %} + {% if post_banner_image %} + "banner_image": {{ post_banner_image | jsonify }}, + {% endif %} + "date_published": "{{ post.date | date_to_xmlschema }}", + "date_modified": "{{ post.last_modified_at | default: post.date | date_to_xmlschema }}", + {% assign post_author = post.author | default: post.authors[0] | default: site.author %} + {% assign post_author = site.data.authors[post_author] | default: post_author %} + {% assign post_author_uri = post_author.uri | default: nil %} + {% assign post_author_name = post_author.name | default: post_author %} + "author": { + "name": {{ post_author_name | default: "" | jsonify }} + {% if post_author_uri != nil %} + , "url": {{ post_author_uri | jsonify }} + {% endif %} + }, + "tags": {{ post.tags | uniq | jsonify }} + }{% unless forloop.last == true %},{% endunless %} + {% endfor %} + ] +} diff --git a/feed.blog.xml b/feed.blog.xml new file mode 100644 index 0000000..b9bc71d --- /dev/null +++ b/feed.blog.xml @@ -0,0 +1,27 @@ +--- +layout: +--- + + + + <![CDATA[{{ site.title }}]]> + + + {{ site.time | date_to_xmlschema }} + {{ site.url }}/ + + + {% if site.email %}{% endif %} + + Octopress + + {% for post in site.categories.blog limit: 20 %} + + <![CDATA[{{ post.title | cdata_escape }}]]> + + {{ post.date | date_to_xmlschema }} + {{ site.url }}{{ post.id }} + + + {% endfor %} + diff --git a/feed.json b/feed.json index 1116e09..632608d 100644 --- a/feed.json +++ b/feed.json @@ -26,7 +26,7 @@ layout: }, {% endif %} "items": [ - {% assign posts = site.posts | where_exp: "post", "post.draft != true" | where_exp: "post", "post.categories contains 'blog'" %} + {% assign posts = site.posts | where_exp: "post", "post.draft != true" %} {% for post in posts limit: 20 %} { "id": {{ post.id | absolute_url | jsonify }}, diff --git a/feed.xml b/feed.xml index b9bc71d..4c37c5b 100644 --- a/feed.xml +++ b/feed.xml @@ -15,7 +15,7 @@ layout: Octopress - {% for post in site.categories.blog limit: 20 %} + {% for post in site.posts limit: 20 %} <![CDATA[{{ post.title | cdata_escape }}]]>