/
feed.json
77 lines (77 loc) · 2.87 KB
/
feed.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
"version": "https://jsonfeed.org/version/1",
{% assign site_title = site.title | site.name %}
{% if site_title %}
"title": {{ site_title | smartify | json }},
{% endif %}
{% if site.description %}
"description": {{ site.description | json }},
{% endif %}
"home_page_url": "{{ '/' | absolute_url }}",
"feed_url": "{{ page.url | absolute_url }}",
"icon": "{{ "/apple-touch-icon.png" | absolute_url }}",
"favicon": "{{ "/favicon.ico" | absolute_url }}",
"expired": false,
{% if site.author %}
"author": {
"name": {{ site.author.name | default: site.author | json }},
{% if site.author.uri %}
"url": {{ site.author.uri | json }}
{% endif %}
},
{% endif %}
"items": [
{% assign posts = site.posts | where_exp: "post", "post.draft != true" %}
{% for post in posts limit: 10 %}
{
"id": {{ post.id | absolute_url | json }},
"url": "{{ post.url | absolute_url }}",
"title": {{ post.title | smartify | strip_html | normalize_whitespace | json }},
{% if post.excerpt and post.excerpt != empty %}
{% assign post_summary = post.excerpt | strip_html | normalize_whitespace | json %}
"content_html": {{ post_summary }},
"summary": {{ post_summary }},
{% 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 }}",
{% 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] %}
{% if post_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": {
{% if post_author_name %}
"name": {{ post_author_name | json }},
{% endif %}
{% if post_author_uri %}
"url": {{ post_author_uri | json }}
{% endif %}
},
{% endif %}
{% if post.enclosure %}
"attachments": [
{
"url": "{{ post.enclosure }}",
"mime_type": "{{ post.enclosure_type }}",
"size_in_bytes": "{{ post.enclosure_length }}"
}
],
{% endif %}
"tags": [
{% for tag in post.tags %}
{{ tag | json }}
{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}