From c48b61ad72b73bd94e6c3a361a66a36900f40898 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 24 Apr 2023 05:56:30 +0800 Subject: [PATCH] templates: add base URL for feed content (#2190) Relative links in the entry content do not currently have a base URI, so will be resolved relative to the feed URI: Given an entry with the content: And URIS of: * entry: https://example.org/blog/some-entry/ * feed: https://example.org/atom.xml The link URI will end up as: https://example.org/some-resource.bin rather than the URI that ends up resolved in the rendered page: https://example.org/blog/some-entry/some-resource.bin The atom and RSS formats allow for an xml:base attribute (itself specified in [1]) to provide a base URI of a subset of a document. This change adds xml:base attributes to each entry, using the page permalink. This gives us something equivalent to: ]]> [1]: https://www.w3.org/TR/xmlbase/ Signed-off-by: Jeremy Kerr --- components/templates/src/builtins/atom.xml | 2 +- components/templates/src/builtins/rss.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/templates/src/builtins/atom.xml b/components/templates/src/builtins/atom.xml index 8b2d331e5..2f1609556 100644 --- a/components/templates/src/builtins/atom.xml +++ b/components/templates/src/builtins/atom.xml @@ -40,7 +40,7 @@ {% if page.summary %} {{ page.summary }} {% else %} - {{ page.content }} + {{ page.content }} {% endif %} {%- endfor %} diff --git a/components/templates/src/builtins/rss.xml b/components/templates/src/builtins/rss.xml index 1c09e4cf4..a684a48af 100644 --- a/components/templates/src/builtins/rss.xml +++ b/components/templates/src/builtins/rss.xml @@ -33,7 +33,7 @@ {{ page.permalink | escape_xml | safe }} {{ page.permalink | escape_xml | safe }} - {% if page.summary %}{{ page.summary }}{% else %}{{ page.content }}{% endif %} + {% if page.summary %}{{ page.summary }}{% else %}{{ page.content }}{% endif %} {%- endfor %}