From 6950c0772c9582c2ec63b30272948c5540811e9e Mon Sep 17 00:00:00 2001 From: Parker TenBroeck <51721964+ParkerTenBroeck@users.noreply.github.com> Date: Fri, 16 Jan 2026 22:29:36 -0500 Subject: [PATCH] improving feeds --- templates/base.html | 12 ++++++++---- templates/macros/feed.html | 10 ++++++++++ templates/taxonomy_single.html | 10 ++++------ 3 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 templates/macros/feed.html diff --git a/templates/base.html b/templates/base.html index 0a470ef..c01ce32 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,3 +1,5 @@ +{% import "macros/feed.html" as feed_macros %} + @@ -14,10 +16,12 @@ {%- endblock -%} - {% block feeds %} - - - {% endblock %} + {%- if config.generate_feeds %} + {%- for feed in config.feed_filenames -%} + {{ feed_macros::link_alternate(filename=feed, title=config.title) }} + {% endfor -%} + {%- block feeds -%}{%- endblock -%} + {% endif %} diff --git a/templates/macros/feed.html b/templates/macros/feed.html new file mode 100644 index 0000000..ad9315e --- /dev/null +++ b/templates/macros/feed.html @@ -0,0 +1,10 @@ +{%- macro link_alternate(filename, title) -%} + {%- if filename is ending_with("atom.xml") -%} + {%- set type = 'type="application/atom+xml" ' -%} + {%- elif filename is ending_with("rss.xml") -%} + {%- set type = 'type="application/rss+xml" ' -%} + {%- elif filename is ending_with(".json") -%} + {%- set type = 'type="application/feed+json" ' -%} + {%- endif -%} + +{%- endmacro -%} \ No newline at end of file diff --git a/templates/taxonomy_single.html b/templates/taxonomy_single.html index 03410c7..b589d19 100644 --- a/templates/taxonomy_single.html +++ b/templates/taxonomy_single.html @@ -1,12 +1,13 @@ {% extends "base.html" %} {% import "macros/taxonomy.html" as macros %} {% import "macros/post.html" as posts %} +{% import "macros/feed.html" as feed_macros %} {%- block title -%} {{ term.name | title }} | {{ config.title }} {%- endblock -%} -{# {%- block feeds -%} +{%- block feeds -%} {%- if taxonomy.feed -%} {%- for filename in config.feed_filenames -%} @@ -18,14 +19,11 @@ {%- set feed_title = config.title ~ " | Posts in the '" ~ term.name ~ "' " ~ singular_name -%} {%- set feed_filename = taxonomy.name ~ "/" ~ term.name ~ "/" ~ filename -%} {{ feed_macros::link_alternate(filename=feed_filename, title=feed_title) }} + {% endfor -%} {%- endif -%} -{%- endblock -%} #} +{%- endblock -%} -{% block rss %} - {% set rss_path = "tags/" ~ term.name ~ "/rss.xml" %} - -{% endblock rss %} {%- block main -%}