1
0
mirror of https://github.com/danbee/danbarber.me synced 2025-03-04 08:59:10 +00:00

Add everything feed

This commit is contained in:
Daniel Barber 2019-07-14 18:42:07 -04:00
parent d25a245db8
commit ad182cf2b7
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
5 changed files with 99 additions and 2 deletions

View File

@ -12,6 +12,10 @@
<!-- Links -->
<link rel="alternate" type="application/atom+xml" title="{{site.title}}" href="{{ site.url }}/feed.xml">
<link rel="alternate" type="application/json" title="{{site.title}}" href="{{ site.url }}/feed.json">
<link rel="alternate" type="application/atom+xml" title="{{site.title}} - Blog" href="{{ site.url }}/feed.blog.xml">
<link rel="alternate" type="application/json" title="{{site.title}} - Blog" href="{{ site.url }}/feed.blog.json">
<link rel="alternate" type="application/atom+xml" title="{{site.title}} - Photos" href="{{ site.url }}/feed.photos.xml">
<link rel="alternate" type="application/json" title="{{site.title}} - Photos" href="{{ site.url }}/feed.photos.json">

66
feed.blog.json Normal file
View File

@ -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 %}
]
}

27
feed.blog.xml Normal file
View File

@ -0,0 +1,27 @@
---
layout:
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[{{ site.title }}]]></title>
<link href="{{ site.url }}/atom.xml" rel="self"/>
<link href="{{ site.url }}/"/>
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ site.url }}/</id>
<author>
<name><![CDATA[{{ site.author | strip_html }}]]></name>
{% if site.email %}<email><![CDATA[{{ site.email }}]]></email>{% endif %}
</author>
<generator uri="http://octopress.org/">Octopress</generator>
{% for post in site.categories.blog limit: 20 %}
<entry>
<title type="html"><![CDATA[{{ post.title | cdata_escape }}]]></title>
<link href="{{ site.url }}{{ post.url }}"/>
<updated>{{ post.date | date_to_xmlschema }}</updated>
<id>{{ site.url }}{{ post.id }}</id>
<content type="html"><![CDATA[{{ post.content | expand_urls: site.url | cdata_escape }}]]></content>
</entry>
{% endfor %}
</feed>

View File

@ -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 }},

View File

@ -15,7 +15,7 @@ layout:
</author>
<generator uri="http://octopress.org/">Octopress</generator>
{% for post in site.categories.blog limit: 20 %}
{% for post in site.posts limit: 20 %}
<entry>
<title type="html"><![CDATA[{{ post.title | cdata_escape }}]]></title>
<link href="{{ site.url }}{{ post.url }}"/>