From b8a1314251176159dc82e470ad7e871feb9d9039 Mon Sep 17 00:00:00 2001 From: Thibault Martin Date: Fri, 1 Sep 2023 12:01:58 +0200 Subject: [PATCH] Limit the RSS feed to 15 entries (#1999) * 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 d15810bc5ae713c770fa163b457db6e3ea475ec9. --- templates/atom.xml | 28 +++++++++------------------- templates/macros/atom.html | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 templates/macros/atom.html diff --git a/templates/atom.xml b/templates/atom.xml index acdd6b2e3..fce3af4cd 100644 --- a/templates/atom.xml +++ b/templates/atom.xml @@ -1,3 +1,4 @@ +{% import "macros/atom.html" as atom %} {{ config.title }} @@ -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 }} - {{ page.date | date(format="%+") }} - {{ page.updated | default(value=page.date) | date(format="%+") }} - - - {%- if page.authors -%} - {{ page.authors[0] }} - {%- elif config.author -%} - {{ config.author }} - {%- else -%} - Unknown - {%- endif -%} - - - - {{ page.permalink | safe }} - {{ page.content }} - + {{ atom::entry(page=page) }} {%- endfor %} + {% endif %} diff --git a/templates/macros/atom.html b/templates/macros/atom.html new file mode 100644 index 000000000..5deb94d8f --- /dev/null +++ b/templates/macros/atom.html @@ -0,0 +1,21 @@ +{% macro entry(page) %} + + {{ page.title }} + {{ page.date | date(format="%+") }} + {{ page.updated | default(value=page.date) | date(format="%+") }} + + + {%- if page.authors -%} + {{ page.authors[0] }} + {%- elif config.author -%} + {{ config.author }} + {%- else -%} + Unknown + {%- endif -%} + + + + {{ page.permalink | safe }} + {{ page.content }} + +{% endmacro %}