Skip to content

Commit 28f33e3

Browse files
Adds atom template with logic for multiple RSS feeds (#327)
### Description This pulls in source for the pre-built atom feed from zola, adds logic to filter by "section", overrides the pre-built atom feed, and enables an event-only feed. In the end, the main atom feed (`/atom.xml`) is just blog posts. There is now an additional atom feed for events section `/events/atom.xml`) and for any future sections that enable the feed generaiton. ### Issues Resolved #322 ### Check List - [x] Commits are signed per the DCO using `--signoff` By submitting this pull request, I confirm that my contribution is made under the terms of the BSD-3-Clause License. --------- Signed-off-by: Kyle J. Davis <[email protected]> Signed-off-by: Madelyn Olson <[email protected]> Co-authored-by: Madelyn Olson <[email protected]>
1 parent 0bb508b commit 28f33e3

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

content/events/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
title = "Events"
33
template = "events.html"
44
page_template = "event-page.html"
5+
generate_feeds = true
56
+++

templates/atom.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{# built from https://github.com/getzola/zola/blob/master/components/templates/src/builtins/rss.xml / MIT #}<?xml version="1.0" encoding="UTF-8"?>
2+
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ lang }}">
3+
<title>{{ config.title }}
4+
{%- if term %} - {{ term.name }}
5+
{%- elif section.title %} - {{ section.title }}
6+
{%- endif -%}
7+
</title>
8+
{%- if config.description %}
9+
<subtitle>{{ config.description }}</subtitle>
10+
{%- endif %}
11+
<link rel="self" type="application/atom+xml" href="{{ feed_url | safe }}"/>
12+
<link rel="alternate" type="text/html" href="
13+
{%- if section -%}
14+
{{ section.permalink | escape_xml | safe }}{%- set section_id = section.components[0] -%}
15+
{%- else -%}
16+
{{ config.base_url | escape_xml | safe }}
17+
{%- endif -%}
18+
"/>
19+
20+
<generator uri="https://www.getzola.org/">Zola</generator>
21+
{% if last_updated is defined %}<updated>{{ last_updated | date(format="%+") }}</updated>{% endif %}
22+
<id>{{ feed_url | safe }}</id>
23+
{%- for page in pages %}
24+
25+
{%- if (page.components[0] == "blog") or (section_id and section_id == page.components[0]) -%}
26+
<entry xml:lang="{{ page.lang }}">
27+
<title>{{ page.title }}</title>
28+
<published>{{ page.date | date(format="%+") }}</published>
29+
<updated>{{ page.updated | default(value=page.date) | date(format="%+") }}</updated>
30+
{% for author in page.authors %}
31+
<author>
32+
<name>
33+
{{ author }}
34+
</name>
35+
</author>
36+
{% else %}
37+
<author>
38+
<name>
39+
{%- if config.author -%}
40+
{{ config.author }}
41+
{%- else -%}
42+
Unknown
43+
{%- endif -%}
44+
</name>
45+
</author>
46+
{% endfor %}
47+
<link rel="alternate" type="text/html" href="{{ page.permalink | safe }}"/>
48+
<id>{{ page.permalink | safe }}</id>
49+
{% if page.summary %}
50+
<summary type="html">{{ page.summary }}</summary>
51+
{% else %}
52+
<content type="html" xml:base="{{ page.permalink | escape_xml | safe }}">{{ page.content }}</content>
53+
{% endif %}
54+
</entry>
55+
{%- endif -%}
56+
{%- endfor %}
57+
</feed>

0 commit comments

Comments
 (0)