-
Notifications
You must be signed in to change notification settings - Fork 299
/
Copy pathfeed.xml
38 lines (36 loc) · 2.36 KB
/
feed.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{% import "macros.html" as macros -%}
{% set section_path = feed_url | trim_start_matches(pat=config.base_url ~ "/") | trim_end_matches(pat="feed.xml") -%}
{% set section = get_section(path=section_path ~ "_index.md") -%}
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<generator uri="https://blog.rust-lang.org{{ section.path | safe }}" version="0.1.0">{{ section.title }}</generator>
<link href="https://blog.rust-lang.org{{ section.path | safe }}feed.xml" rel="self" type="application/atom+xml" />
<link href="https://blog.rust-lang.org{{ section.path | safe }}" rel="alternate" type="text/html" />
<id>https://blog.rust-lang.org{{ section.path | safe }}</id>
<title>{{ section.title }}</title>
<subtitle>{{ section.description }}</subtitle>
<author>
<name>Maintained by {{ section.extra.maintained_by }}.</name>
<uri>https://github.com/rust-lang/blog.rust-lang.org/</uri>
</author>
<updated>{{ now() | date(format="%Y-%m-%dT%H:%M:%S+00:00") }}</updated>
{% for page in section.pages | reverse %}
<entry>
<title>{{ macros::escape_hbs(input=page.title) | safe }}</title>
<link rel="alternate" href="https://blog.rust-lang.org{{ macros::escape_hbs(input=page.path) | safe }}" type="text/html" title="{{ macros::escape_hbs(input=page.title) | safe }}" />
{%- set num_comps = page.components | length %}
{%- if num_comps < 4 %}{{ throw(message="Missing date in 'path' key, required format: '[inside-rust/]YYYY/MM/DD/slug-of-your-choice'") }}{% endif %}
{%- set year = page.components | nth(n=num_comps - 4) %}
{%- set month = page.components | nth(n=num_comps - 3) %}
{%- set day = page.components | nth(n=num_comps - 2) %}
<published>{{ year }}-{{ month }}-{{ day }}T00:00:00+00:00</published>
<updated>{{ year }}-{{ month }}-{{ day }}T00:00:00+00:00</updated>
<id>https://blog.rust-lang.org{{ macros::escape_hbs(input=page.path) | safe }}</id>
<content type="html" xml:base="https://blog.rust-lang.org{{ macros::escape_hbs(input=page.path) | safe }}">{{ macros::escape_hbs(input=page.content) }}</content>
<author>
<name>{{ macros::escape_hbs(input=page.authors | join(sep=", ")) }}</name>
</author>
</entry>
{%- if loop.index == 10 %}{% break %}{% endif %}
{%- endfor %}
</feed>