Skip to content

Commit 2cd2076

Browse files
committed
Generate feeds
1 parent 21fb92b commit 2cd2076

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

Diff for: config.toml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
base_url = "https://blog.rust-lang.org"
44
compile_sass = true
5+
generate_feeds = true
6+
feed_filenames = ["feed.xml", "releases.json"]
57
build_search_index = false
68

79
[markdown]

Diff for: content/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
+++
22
title = "Rust Blog"
33
description = "Empowering everyone to build reliable and efficient software."
4+
generate_feeds = true
45
[extra]
56
index_title = "The Rust Programming Language Blog"
67
index_html = """

Diff for: content/inside-rust/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
+++
22
title = "Inside Rust Blog"
33
description = "Want to follow along with Rust development? Curious how you might get involved? Take a look!"
4+
generate_feeds = true
45
[extra]
56
index_title = 'The "Inside Rust" Blog'
67
index_html = """

Diff for: templates/feed.xml

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
1-
{% import "macros.html" as macros %}
1+
{% import "macros.html" as macros -%}
2+
{% set section_path = feed_url | trim_start_matches(pat=config.base_url ~ "/") | trim_end_matches(pat="feed.xml") -%}
3+
{% set section = get_section(path=section_path ~ "_index.md") -%}
24
<?xml version="1.0" encoding="utf-8"?>
35
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
4-
<generator uri="https://blog.rust-lang.org/{{ section.path }}" version="0.1.0">{{ section.title }}</generator>
5-
<link href="https://blog.rust-lang.org/{{ section.path }}feed.xml" rel="self" type="application/atom+xml" />
6-
<link href="https://blog.rust-lang.org/{{ section.path }}" rel="alternate" type="text/html" />
7-
<id>https://blog.rust-lang.org/{{ section.path }}</id>
6+
<generator uri="https://blog.rust-lang.org{{ section.path | safe }}" version="0.1.0">{{ section.title }}</generator>
7+
<link href="https://blog.rust-lang.org{{ section.path | safe }}feed.xml" rel="self" type="application/atom+xml" />
8+
<link href="https://blog.rust-lang.org{{ section.path | safe }}" rel="alternate" type="text/html" />
9+
<id>https://blog.rust-lang.org{{ section.path | safe }}</id>
810
<title>{{ section.title }}</title>
911
<subtitle>{{ section.description }}</subtitle>
1012
<author>
11-
<name>Maintained by {{ section.maintained_by }}.</name>
13+
<name>Maintained by {{ section.extra.maintained_by }}.</name>
1214
<uri>https://github.com/rust-lang/blog.rust-lang.org/</uri>
1315
</author>
14-
<updated>{{feed_updated}}</updated>
16+
<updated>{{ now() | date(format="%Y-%m-%dT%H:%M:%S+00:00") }}</updated>
1517

16-
{% for page in pages %}
18+
{% for page in section.pages | reverse %}
1719
<entry>
18-
<title>{{ macros::escape_hbs(input=page.title) }}</title>
19-
<link rel="alternate" href="https://blog.rust-lang.org/{{ section.path }}{{ macros::escape_hbs(input=page.path) }}" type="text/html" title="{{ macros::escape_hbs(input=page.title) }}" />
20-
<published>{{ macros::escape_hbs(input=page.published) }}</published>
21-
<updated>{{ macros::escape_hbs(input=page.updated) }}</updated>
22-
<id>https://blog.rust-lang.org/{{ section.path }}{{ macros::escape_hbs(input=page.path) }}</id>
23-
<content type="html" xml:base="https://blog.rust-lang.org/{{ section.path }}{{ macros::escape_hbs(input=page.path) }}">{{ macros::escape_hbs(input=page.contents) }}</content>
20+
<title>{{ macros::escape_hbs(input=page.title) | safe }}</title>
21+
<link rel="alternate" href="https://blog.rust-lang.org{{ section.path | trim_end_matches(pat="/") }}{{ macros::escape_hbs(input=page.path) | safe }}" type="text/html" title="{{ macros::escape_hbs(input=page.title) | safe }}" />
22+
{%- set year = page.components[0] | int %}
23+
{%- set month = page.components[1] | int %}
24+
{%- set day = page.components[2] | int %}
25+
<published>{{ year }}-{{ month }}-{{ day }}T00:00:00+00:00</published>
26+
<updated>{{ year }}-{{ month }}-{{ day }}T00:00:00+00:00</updated>
27+
<id>https://blog.rust-lang.org{{ section.path | trim_end_matches(pat="/") }}{{ macros::escape_hbs(input=page.path) | safe }}</id>
28+
<content type="html" xml:base="https://blog.rust-lang.org{{ section.path | trim_end_matches(pat="/") }}{{ macros::escape_hbs(input=page.path) | safe }}">{{ macros::escape_hbs(input=page.content) }}</content>
2429

2530
<author>
26-
<name>{{ macros::escape_hbs(input=page.author) }}</name>
31+
<name>{{ macros::escape_hbs(input=page.authors | join(sep=", ")) }}</name>
2732
</author>
2833
</entry>
2934
{%- endfor %}

Diff for: templates/releases.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% set section_path = feed_url | trim_start_matches(pat=config.base_url ~ "/") | trim_end_matches(pat="releases.json") -%}
2+
{% set section = get_section(path=section_path ~ "_index.md") -%}
3+
{"releases":[{% filter trim_end_matches(pat=",") %}{%- for page in section.pages | reverse -%}{% if page.extra is containing("release") %}{"title":"{{ page.title }}","url":"{{ page.path | trim_start_matches(pat="/") }}"},{% endif %}{% endfor %}{% endfilter %}],"feed_updated":"{{ now() | date(format="%Y-%m-%dT%H:%M:%S+00:00") }}"}

0 commit comments

Comments
 (0)