Skip to content

Instantly share code, notes, and snippets.

@d2s
Created May 19, 2022 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d2s/be040fe0ddcb707f4f192f86cda11a14 to your computer and use it in GitHub Desktop.
Save d2s/be040fe0ddcb707f4f192f86cda11a14 to your computer and use it in GitHub Desktop.
JSON Feed template for Eleventy site generator
---json
{
"permalink": "/feed.json",
"eleventyExcludeFromCollections": true
}
---
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ config.name }}",
"home_page_url": "{{ config.url }}",
"feed_url": "{{ config.url }}{{ permalink }}",
"description": "{{ config.shortDesc }}",
"author": {
"name": "{{ config.authorName }}",
"url": "{{ config.url }}"
},
"items": [
{%- for post in collections.posts | reverse %}
{%- set absolutePostUrl %}{{ post.url | url | absoluteUrl(config.url) }}{% endset -%}
{
"id": "{{ absolutePostUrl }}",
"url": "{{ absolutePostUrl }}",
"title": "{{ post.data.title }}",
"content_html": {% if post.templateContent %}{{ post.templateContent | dump | safe }}{% else %}""{% endif %},
"date_published": "{{ post.date | dateToRfc3339 }}"
}
{% if not loop.last %},{% endif %}
{%- endfor %}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment