From b106d42f4d7bcea194a2f04d4034ef3fec699081 Mon Sep 17 00:00:00 2001 From: Parker TenBroeck <51721964+ParkerTenBroeck@users.noreply.github.com> Date: Sat, 2 May 2026 10:52:48 -0400 Subject: [PATCH] photos properly included in RSS and Atom feed --- templates/atom.xml | 54 +++++++++++++++++++++++++++++++++++ templates/macros/feed.html | 15 +++++++++- templates/macros/figures.html | 2 +- templates/rss.xml | 42 +++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 templates/atom.xml create mode 100644 templates/rss.xml diff --git a/templates/atom.xml b/templates/atom.xml new file mode 100644 index 0000000..2a9bae9 --- /dev/null +++ b/templates/atom.xml @@ -0,0 +1,54 @@ +{% import "macros/feed.html" as feed_macros %} + + + + {{ config.title }} + {%- if term %} - {{ term.name }} + {%- elif section.title %} - {{ section.title }} + {%- endif -%} + + {%- if config.description %} + {{ config.description }} + {%- endif %} + + + Zola + {% if last_updated is defined %}{{ last_updated | date(format="%+") }}{% endif %} + {{ feed_url | safe }} + {%- for page in pages %} + + {{ page.title }} + {{ page.date | date(format="%+") }} + {{ page.updated | default(value=page.date) | date(format="%+") }} + {% for author in page.authors %} + + + {{ author }} + + + {% else %} + + + {%- if config.author -%} + {{ config.author }} + {%- else -%} + Unknown + {%- endif -%} + + + {% endfor %} + + {{ page.permalink | safe }} + {% if page.description %} + {{ page.description }} + {% endif %} + {{ feed_macros::content(page=page) }} + + {%- endfor %} + \ No newline at end of file diff --git a/templates/macros/feed.html b/templates/macros/feed.html index ad9315e..12be2b1 100644 --- a/templates/macros/feed.html +++ b/templates/macros/feed.html @@ -1,3 +1,5 @@ +{% import "macros/figures.html" as figures %} + {%- macro link_alternate(filename, title) -%} {%- if filename is ending_with("atom.xml") -%} {%- set type = 'type="application/atom+xml" ' -%} @@ -7,4 +9,15 @@ {%- set type = 'type="application/feed+json" ' -%} {%- endif -%} -{%- endmacro -%} \ No newline at end of file +{%- endmacro -%} + + + +{%- macro content(page) -%} + + {%if page.taxonomies.category is containing("photo") %} + {{ figures::image(src=page.extra.picture_src, caption=page.description) }} + {% else %} + {% if page.summary %}{{ page.summary }}{% else %}{{ page.content }}{% endif %} + {% endif %} +{%- endmacro -%} diff --git a/templates/macros/figures.html b/templates/macros/figures.html index c9406ac..fb4e093 100644 --- a/templates/macros/figures.html +++ b/templates/macros/figures.html @@ -3,7 +3,7 @@ {# {% set image = resize_image(path=src, height=mdata.height, width=mdata.width, format="webp") %} #}
- {{caption | default(value='')}} + {{caption | default(value='')}} {% if caption != "" %}
{{ caption | markdown() | safe }}
{% endif %} diff --git a/templates/rss.xml b/templates/rss.xml new file mode 100644 index 0000000..9641ee2 --- /dev/null +++ b/templates/rss.xml @@ -0,0 +1,42 @@ +{% import "macros/feed.html" as feed_macros %} + + + + + {{ config.title }} + {%- if term %} - {{ term.name }} + {%- elif section.title %} - {{ section.title }} + {%- endif -%} + + + {%- if section -%} + {{ section.permalink | escape_xml | safe }} + {%- else -%} + {{ config.base_url | escape_xml | safe }} + {%- endif -%} + + {{ config.description }} + Zola + {{ lang }} + + {% if last_updated is defined %}{{ last_updated | date(format="%a, %d %b %Y %H:%M:%S %z") }}{% endif %} + {%- for page in pages %} + + {{ page.title }} + {{ page.date | date(format="%a, %d %b %Y %H:%M:%S %z") }} + + {%- if page.authors -%} + {{ page.authors[0] }} + {%- elif config.author -%} + {{ config.author }} + {%- else -%} + Unknown + {%- endif -%} + + {{ page.permalink | escape_xml | safe }} + {{ page.permalink | escape_xml | safe }} + {{ feed_macros::content(page=page) }} + + {%- endfor %} + + \ No newline at end of file