Atom template authors (#2259)

* templates:atom: add support for multiple authors

Atom 1.0 [0] support multiple `<author>` entries in the feed. This commit
modified the template to generate as many `<author>` as the page's
metadata contains.

[0] https://validator.w3.org/feed/docs/atom.html#recommendedEntryElements

* Test we can have multiple authors in ATOM feeds
This commit is contained in:
Heitor 2023-07-26 18:18:39 -03:00 committed by Vincent Prouillet
parent c18a0c8031
commit a1ac81681b
3 changed files with 15 additions and 3 deletions

View File

@ -680,6 +680,11 @@ fn can_build_feeds() {
assert!(file_contains!(public, "posts/tutorials/programming/atom.xml", "Rust"));
// It doesn't contain articles from other sections
assert!(!file_contains!(public, "posts/tutorials/programming/atom.xml", "Extra Syntax"));
// Test Atom feed entry with 3 authors
assert!(file_contains!(public, "posts/tutorials/programming/atom.xml", "Foo Doe"));
assert!(file_contains!(public, "posts/tutorials/programming/atom.xml", "Bar Doe"));
assert!(file_contains!(public, "posts/tutorials/programming/atom.xml", "Baz Doe"));
}
#[test]

View File

@ -24,17 +24,23 @@
<title>{{ page.title }}</title>
<published>{{ page.date | date(format="%+") }}</published>
<updated>{{ page.updated | default(value=page.date) | date(format="%+") }}</updated>
{% for author in page.authors %}
<author>
<name>
{%- if page.authors -%}
{{ page.authors[0] }}
{%- elif config.author -%}
{{ author }}
</name>
</author>
{% else %}
<author>
<name>
{%- if config.author -%}
{{ config.author }}
{%- else -%}
Unknown
{%- endif -%}
</name>
</author>
{% endfor %}
<link rel="alternate" href="{{ page.permalink | safe }}" type="text/html"/>
<id>{{ page.permalink | safe }}</id>
{% if page.summary %}

View File

@ -2,6 +2,7 @@
title = "Rust"
weight = 2
date = 2017-01-01
authors = ["Foo Doe", "Bar Doe", "Baz Doe"]
+++
A simple page