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: <a href="some-resource.bin"> 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: <entry> <content xml:base="https://example.org/blog/some-entry/"> <![CDATA[ <a href="some-resource.bin"> ]]> </content> </entry> [1]: https://www.w3.org/TR/xmlbase/ Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
This commit is contained in:
parent
c61e925073
commit
63054a96d2
@ -40,7 +40,7 @@
|
||||
{% if page.summary %}
|
||||
<summary type="html">{{ page.summary }}</summary>
|
||||
{% else %}
|
||||
<content type="html">{{ page.content }}</content>
|
||||
<content type="html" xml:base="{{ page.permalink | escape_xml | safe }}">{{ page.content }}</content>
|
||||
{% endif %}
|
||||
</entry>
|
||||
{%- endfor %}
|
||||
|
@ -33,7 +33,7 @@
|
||||
</author>
|
||||
<link>{{ page.permalink | escape_xml | safe }}</link>
|
||||
<guid>{{ page.permalink | escape_xml | safe }}</guid>
|
||||
<description>{% if page.summary %}{{ page.summary }}{% else %}{{ page.content }}{% endif %}</description>
|
||||
<description xml:base="{{ page.permalink | escape_xml | safe }}">{% if page.summary %}{{ page.summary }}{% else %}{{ page.content }}{% endif %}</description>
|
||||
</item>
|
||||
{%- endfor %}
|
||||
</channel>
|
||||
|
Loading…
Reference in New Issue
Block a user