Skip to content

Commit 4aa7b1f

Browse files
committed
Rename template variables
Zola uses 'section' and 'page' instead of 'blog' and 'post'.
1 parent a9e53dd commit 4aa7b1f

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Generator {
142142

143143
let data = json!({
144144
"title": blog.index_title(),
145-
"blog": blog,
145+
"section": blog,
146146
"other_blogs": other_blogs,
147147
});
148148
let path = blog.prefix().join("index.html");
@@ -164,8 +164,8 @@ impl Generator {
164164

165165
let data = json!({
166166
"title": format!("{} | {}", post.title, blog.title()),
167-
"blog": blog,
168-
"post": post,
167+
"section": blog,
168+
"page": post,
169169
});
170170

171171
let path = path.join(filename);
@@ -176,7 +176,7 @@ impl Generator {
176176
fn render_feed(&self, blog: &Blog) -> eyre::Result<()> {
177177
let posts: Vec<_> = blog.posts().iter().take(10).collect();
178178
let data = json!({
179-
"blog": blog,
179+
"section": blog,
180180
"posts": posts,
181181
"feed_updated": chrono::Utc::now().with_nanosecond(0).unwrap().to_rfc3339(),
182182
});

templates/feed.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
{% import "macros.html" as macros %}
22
<?xml version="1.0" encoding="utf-8"?>
33
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
4-
<generator uri="https://blog.rust-lang.org/{{blog.prefix}}" version="0.1.0">{{blog.title}}</generator>
5-
<link href="https://blog.rust-lang.org/{{blog.prefix}}feed.xml" rel="self" type="application/atom+xml" />
6-
<link href="https://blog.rust-lang.org/{{blog.prefix}}" rel="alternate" type="text/html" />
7-
<id>https://blog.rust-lang.org/{{blog.prefix}}</id>
8-
<title>{{blog.title}}</title>
9-
<subtitle>{{blog.description}}</subtitle>
4+
<generator uri="https://blog.rust-lang.org/{{ section.prefix }}" version="0.1.0">{{ section.title }}</generator>
5+
<link href="https://blog.rust-lang.org/{{ section.prefix }}feed.xml" rel="self" type="application/atom+xml" />
6+
<link href="https://blog.rust-lang.org/{{ section.prefix }}" rel="alternate" type="text/html" />
7+
<id>https://blog.rust-lang.org/{{ section.prefix }}</id>
8+
<title>{{ section.title }}</title>
9+
<subtitle>{{ section.description }}</subtitle>
1010
<author>
11-
<name>Maintained by {{blog.maintained_by}}.</name>
11+
<name>Maintained by {{ section.maintained_by }}.</name>
1212
<uri>https://github.com/rust-lang/blog.rust-lang.org/</uri>
1313
</author>
1414
<updated>{{feed_updated}}</updated>
1515

16-
{% for post in posts %}
16+
{% for page in posts %}
1717
<entry>
18-
<title>{{ macros::escape_hbs(input=post.title) }}</title>
19-
<link rel="alternate" href="https://blog.rust-lang.org/{{blog.prefix}}{{ macros::escape_hbs(input=post.url) }}" type="text/html" title="{{ macros::escape_hbs(input=post.title) }}" />
20-
<published>{{ macros::escape_hbs(input=post.published) }}</published>
21-
<updated>{{ macros::escape_hbs(input=post.updated) }}</updated>
22-
<id>https://blog.rust-lang.org/{{blog.prefix}}{{ macros::escape_hbs(input=post.url) }}</id>
23-
<content type="html" xml:base="https://blog.rust-lang.org/{{blog.prefix}}{{ macros::escape_hbs(input=post.url) }}">{{ macros::escape_hbs(input=post.contents) }}</content>
18+
<title>{{ macros::escape_hbs(input=page.title) }}</title>
19+
<link rel="alternate" href="https://blog.rust-lang.org/{{ section.prefix }}{{ macros::escape_hbs(input=page.url) }}" 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.prefix }}{{ macros::escape_hbs(input=page.url) }}</id>
23+
<content type="html" xml:base="https://blog.rust-lang.org/{{ section.prefix }}{{ macros::escape_hbs(input=page.url) }}">{{ macros::escape_hbs(input=page.contents) }}</content>
2424

2525
<author>
26-
<name>{{ macros::escape_hbs(input=post.author) }}</name>
26+
<name>{{ macros::escape_hbs(input=page.author) }}</name>
2727
</author>
2828
</entry>
2929
{%- endfor %}

templates/headers.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
{% macro headers(title, blog) -%}
1+
{% macro headers(title, section) -%}
22
<!-- Twitter card -->
33
<meta name="twitter:card" content="summary">
44
<meta name="twitter:site" content="@rustlang">
55
<meta name="twitter:creator" content="@rustlang">
66
<meta name="twitter:title" content="{{ macros::escape_hbs(input=title) }}">
7-
<meta name="twitter:description" content="{{blog.description}}">
7+
<meta name="twitter:description" content="{{ section.description }}">
88
<meta name="twitter:image" content="https://www.rust-lang.org/static/images/rust-social.jpg">
99

1010
<!-- Facebook OpenGraph -->
1111
<meta property="og:title" content="{{ macros::escape_hbs(input=title) }}" />
12-
<meta property="og:description" content="{{blog.description}}">
12+
<meta property="og:description" content="{{ section.description }}">
1313
<meta property="og:image" content="https://www.rust-lang.org/static/images/rust-social-wide.jpg" />
1414
<meta property="og:type" content="website" />
1515
<meta property="og:locale" content="en_US" />
@@ -36,7 +36,7 @@
3636
<meta name="theme-color" content="#ffffff">
3737

3838
<!-- atom -->
39-
<link type="application/atom+xml" rel="alternate" href="https://blog.rust-lang.org/{{blog.prefix}}feed.xml" title="{{blog.title}}" />
39+
<link type="application/atom+xml" rel="alternate" href="https://blog.rust-lang.org/{{ section.prefix }}feed.xml" title="{{ section.title }}" />
4040

4141
<!-- theme switcher -->
4242
<script src="/scripts/theme-switch.js"></script>

templates/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<header class="mt3 mt0-ns mb4-ns">
55
<div class="container flex flex-column flex-row-l justify-between-l">
66
<div class="mw6-l">
7-
<p>{{blog.index_html}}</p>
7+
<p>{{ section.index_html }}</p>
88
</div>
99
</div>
1010
<div class="container flex flex-column flex-row-l justify-between-l">
@@ -23,14 +23,14 @@
2323
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
2424

2525
<table class="post-list collapse w-100 f2-l f2-m f3-s">
26-
{%- for post in blog.posts %}
27-
{% if post.show_year %}<tr>
26+
{%- for page in section.posts %}
27+
{% if page.show_year %}<tr>
2828
<td class="bn"></td>
29-
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">Posts in {{post.year}}</h3></td>
29+
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">Posts in {{ page.year }}</h3></td>
3030
</tr>{% endif %}
3131
<tr>
32-
<td class="tr o-60 pr4 pr5-l bn">{{ macros::month_name(num=post.month) }}&nbsp;{{post.day}}</td>
33-
<td class="bn"><a href="{{post.url}}">{{ macros::escape_hbs(input=post.title) }}</a></td>
32+
<td class="tr o-60 pr4 pr5-l bn">{{ macros::month_name(num=page.month) }}&nbsp;{{ page.day }}</td>
33+
<td class="bn"><a href="{{ page.url }}">{{ macros::escape_hbs(input=page.title) }}</a></td>
3434
</tr>
3535
{%- endfor %}
3636
</table>

templates/layout.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<title>{{ macros::escape_hbs(input=title) }}</title>
1010
<meta name="viewport" content="width=device-width,initial-scale=1.0">
1111
<meta name="description" content="Empowering everyone to build reliable and efficient software.">
12-
{{ headers::headers(title=title, blog=blog) | indent(prefix=" ", blank=true) }}
12+
{{ headers::headers(title=section.index_title, section=section) | indent(prefix=" ", blank=true) }}
1313
</head>
1414
<body>
15-
{{ nav::nav(blog=blog) | indent(prefix=" ", blank=true) }}
15+
{{ nav::nav(section=section) | indent(prefix=" ", blank=true) }}
1616
{%- block page %}{% endblock page %}
1717
{{ footer::footer() | indent(prefix=" ", blank=true) }}
1818
</body>

templates/nav.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
{% macro nav(blog) -%}
1+
{% macro nav(section) -%}
22
<nav class="flex flex-row justify-center justify-end-l items-center flex-wrap ph2 pl3-ns pr4-ns">
33
<div class="brand flex-auto w-100 w-auto-l self-start tc tl-l">
4-
<a href="/{{blog.prefix}}">
4+
<a href="/{{ section.prefix }}">
55
<img class="v-mid ml0-l rust-logo" alt="Rust Logo" src="/images/rust-logo-blk.svg">
6-
<span class="dib ml1 ml0-l">{{blog.title}}</span>
6+
<span class="dib ml1 ml0-l">{{ section.title }}</span>
77
</a>
88
</div>
99

templates/post.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{% import "macros.html" as macros %}
22
{% extends "layout.html" %}
33
{% block page %}
4-
<section id="{{ macros::escape_hbs(input=post.title) }}" class="white">
4+
<section id="{{ macros::escape_hbs(input=page.title) }}" class="white">
55
<div class="w-100 mw-none ph3 mw8-m mw8-l center f3">
66
<header>
7-
<h2>{{ macros::escape_hbs(input=post.title) }}</h2>
7+
<h2>{{ macros::escape_hbs(input=page.title) }}</h2>
88
<div class="highlight mt2 mb3"></div>
99
</header>
1010

11-
<div class="publish-date-author">{{ macros::month_name(num=post.month) }} {{post.day}}, {{post.year}} &middot; {{ macros::escape_hbs(input=post.author) }}
12-
{% if post.has_team %} on behalf of <a href="{{post.team_url}}">{{post.team}}</a> {% endif %}
11+
<div class="publish-date-author">{{ macros::month_name(num=page.month) }} {{ page.day }}, {{ page.year }} &middot; {{ macros::escape_hbs(input=page.author) }}
12+
{% if page.has_team %} on behalf of <a href="{{ page.team_url }}">{{ page.team }}</a> {% endif %}
1313
</div>
1414

1515
<div class="post">
16-
{{ post.contents }}
16+
{{ page.contents }}
1717
</div>
1818
</div>
1919
</section>

0 commit comments

Comments
 (0)