Skip to content

Commit

Permalink
Modifico JSON feed
Browse files Browse the repository at this point in the history
  • Loading branch information
elswork committed Dec 2, 2023
1 parent 40bf738 commit fe63756
Showing 1 changed file with 43 additions and 23 deletions.
66 changes: 43 additions & 23 deletions content/feed/json.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,47 @@
permalink: /feed/feed.json
---
{
"version": "https://jsonfeed.org/version/1.1",
"title": "{{ metadata.title }}",
"language": "{{ metadata.language }}",
"home_page_url": "{{ metadata.url | addPathPrefixToFullUrl }}",
"feed_url": "{{ permalink | htmlBaseUrl(metadata.url) }}",
"description": "{{ metadata.description }}",
"author": {
"name": "{{ metadata.author.name }}",
"url": "{{ metadata.author.url }}"
},
"items": [
{%- for post in collections.posts | reverse %}
{%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.url) %}
{
"id": "{{ absolutePostUrl }}",
"url": "{{ absolutePostUrl }}",
"title": "{{ post.data.title }}",
"content_html": {% if post.templateContent %}{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }}{% else %}""{% endif %},
"date_published": "{{ post.date | dateToRfc3339 }}"
}
{% if not loop.last %},{% endif %}
{%- endfor %}
]
"version": "https://jsonfeed.org/version/1.1",
"title": "{{ metadata.title }}",
"language": "{{ metadata.language }}",
"home_page_url": "{{ metadata.url | addPathPrefixToFullUrl }}",
"feed_url": "{{ permalink | htmlBaseUrl(metadata.url) }}",
"description": "{{ metadata.description }}",
"author": {
"name": "{{ metadata.author.name }}",
"url": "{{ metadata.author.url }}"
},
"items": [
{%- for post in collections.posts | reverse %}
{%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.url) %}
{
"id": "{{ absolutePostUrl }}",
"url": "{{ absolutePostUrl }}",
"title": "{{ post.data.title }}",
"content_html": {{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }},
"date_published": "{{ post.date | dateToRfc3339 }}"
}{% if not loop.last %},{% endif %}
{%- endfor %}

{% for item in collections.customFeed %}
{% set absoluteItemUrl = item.url | htmlBaseUrl(metadata.url) %}
{
"id": "{{ absoluteItemUrl }}",
"url": "{{ absoluteItemUrl }}",
"title": "{{ item.data.title }}",
"content_html": {{ item.templateContent | markdown | dump | safe }},
"date_published": "{{ item.date | dateToRfc3339 }}"
}{% if not loop.last %},{% endif %}
{% endfor %}

{% for issue in issues %}
{
"id": "{{ issue.html_url }}",
"url": "{{ issue.html_url }}",
"title": "{{ issue.title }}",
"content_html": {{ issue.body | markdown | dump | safe }},
"date_published": "{{ issue.created_at }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
]
}

0 comments on commit fe63756

Please sign in to comment.