Skip to content

Commit

Permalink
Limit the RSS feed to 15 entries (#1999)
Browse files Browse the repository at this point in the history
* Limit the RSS feed to 15 entries

* Limit to last entry to test inoreader

* Revert "Limit to last entry to test inoreader"

This reverts commit d15810b.
  • Loading branch information
thibaultamartin authored Sep 1, 2023
1 parent 58f4380 commit b8a1314
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
28 changes: 9 additions & 19 deletions templates/atom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% import "macros/atom.html" as atom %}
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ lang }}">
<title>{{ config.title }}
Expand All @@ -19,25 +20,14 @@
<generator uri="https://www.getzola.org/">Zola</generator>
<updated>{{ last_updated | date(format="%+") }}</updated>
<id>{{ feed_url | safe }}</id>
{% set pageslen = pages | length %}
{% if pageslen > 15 %}
{% for i in range(end=15) %}
{{ atom::entry(page=pages[i]) }}
{% endfor %}
{% else %}
{%- for page in pages %}
<entry xml:lang="{{ page.lang }}">
<title>{{ page.title }}</title>
<published>{{ page.date | date(format="%+") }}</published>
<updated>{{ page.updated | default(value=page.date) | date(format="%+") }}</updated>
<author>
<name>
{%- if page.authors -%}
{{ page.authors[0] }}
{%- elif config.author -%}
{{ config.author }}
{%- else -%}
Unknown
{%- endif -%}
</name>
</author>
<link rel="alternate" href="{{ page.permalink | safe }}" type="text/html"/>
<id>{{ page.permalink | safe }}</id>
<content type="html">{{ page.content }}</content>
</entry>
{{ atom::entry(page=page) }}
{%- endfor %}
{% endif %}
</feed>
21 changes: 21 additions & 0 deletions templates/macros/atom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% macro entry(page) %}
<entry xml:lang="{{ page.lang }}">
<title>{{ page.title }}</title>
<published>{{ page.date | date(format="%+") }}</published>
<updated>{{ page.updated | default(value=page.date) | date(format="%+") }}</updated>
<author>
<name>
{%- if page.authors -%}
{{ page.authors[0] }}
{%- elif config.author -%}
{{ config.author }}
{%- else -%}
Unknown
{%- endif -%}
</name>
</author>
<link rel="alternate" href="{{ page.permalink | safe }}" type="text/html"/>
<id>{{ page.permalink | safe }}</id>
<content type="html">{{ page.content }}</content>
</entry>
{% endmacro %}

0 comments on commit b8a1314

Please sign in to comment.