Skip to content

Commit 85f525f

Browse files
authored
Merge pull request #1579 from rust-lang/senekor/yltumpuuzosp
Add /releases page
2 parents e469842 + 4c7b598 commit 85f525f

File tree

8 files changed

+89
-7
lines changed

8 files changed

+89
-7
lines changed

Diff for: content/_index.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ This is the <b>main Rust blog</b>. \
99
<a href="https://www.rust-lang.org/governance/">Rust teams</a> \
1010
use this blog to announce major developments in the world of Rust."""
1111
maintained_by = "the Rust Teams"
12-
see_also_path = "/inside-rust/"
13-
see_also_text = """the "Inside Rust" blog"""
12+
[[extra.see_also]]
13+
path = "/inside-rust/"
14+
text = """the "Inside Rust" blog"""
15+
[[extra.see_also]]
16+
path = "/releases/"
17+
text = "release announcements"
1418
+++

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ to follow along with Rust development. The various \
1111
use this blog to post status updates, calls for help, and other \
1212
similar announcements."""
1313
maintained_by = "the Rust Teams"
14-
see_also_path = "/"
15-
see_also_text = "the main Rust blog"
14+
[[extra.see_also]]
15+
path = "/"
16+
text = "the main Rust blog"
1617
+++

Diff for: content/releases/_index.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
+++
2+
title = "Rust Release Announcements"
3+
template = "releases.html"
4+
[extra]
5+
index_title = "The Rust Release Announcements"
6+
+++

Diff for: content/releases/latest.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
+++
2+
template = "latest.html"
3+
+++

Diff for: templates/index.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
<div class="mw8-l">
1212
<p>
1313
<b>See also:</b>
14-
<a href="{{ config.base_url | safe }}{{ section.extra.see_also_path | safe }}">{{ section.extra.see_also_text }}</a>
14+
{% for see_also in section.extra.see_also -%}
15+
{% if loop.index0 != 0 %},{% endif %}
16+
<a href="{{ config.base_url | safe }}{{ see_also.path | safe }}">{{ see_also.text }}</a>
17+
{%- endfor -%}
1518
</p>
1619
</div>
1720
</div>

Diff for: templates/latest.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% set section = get_section(path="_index.md") -%}
2+
{%- for page in section.pages | reverse -%}{% if page.extra is containing("release") -%}
3+
<!DOCTYPE html>
4+
<meta charset="utf-8">
5+
<title>Redirect</title>
6+
<meta http-equiv="refresh" content="0; url={{ page.path | safe }}">
7+
<p><a href="{{ page.path | safe }}">Click here</a> to be redirected to the latest Rust release annoucement.</p>
8+
{% break %}{% endif %}{% endfor -%}

Diff for: templates/macros.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
}}
3636
{%- endmacro escape_hbs %}
3737

38-
{% macro show_year(year) -%}
38+
{% macro show_year(year, post_name="Posts") -%}
3939
<tr>
4040
<td class="bn"></td>
41-
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">Posts in {{ year }}</h3></td>
41+
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">{{ post_name }} in {{ year }}</h3></td>
4242
</tr>
4343
{%- endmacro show_year %}

Diff for: templates/releases.html

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{% import "macros.html" as macros -%}
2+
{% extends "layout.html" -%}
3+
{% block page -%}
4+
<header class="mt3 mt0-ns mb4-ns">
5+
<div class="container flex flex-column flex-row-l justify-between-l">
6+
<div class="mw6-l">
7+
<p>
8+
This is a subset of the <a href="/">main Rust blog</a>
9+
listing only official release annoucement posts.
10+
</p>
11+
<p>
12+
Did you know? There are convenient redirects for
13+
the latest and specific release posts:
14+
<br/><a href="/releases/latest">/releases/latest</a>
15+
<br/><a href="/releases/1.85.0">/releases/1.85.0</a>
16+
</p>
17+
</div>
18+
</div>
19+
</header>
20+
21+
{% set section = get_section(path="_index.md") -%}
22+
<section id="posts" class="posts">
23+
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
24+
25+
<table class="post-list collapse w-100 f2-l f2-m f3-s">
26+
{%- set rev_pages = section.pages | reverse %}
27+
{%- for page in rev_pages %}
28+
{%- set num_comps = page.components | length %}
29+
{%- set year = page.components | nth(n=num_comps - 4) | int %}
30+
{%- set month = page.components | nth(n=num_comps - 3) | int %}
31+
{%- set day = page.components | nth(n=num_comps - 2) | int %}
32+
{%- if loop.index0 == 0 %}
33+
{{ macros::show_year(year=year, post_name="Releases") }}
34+
{%- endif %}
35+
36+
{%- if page.extra is containing("release") %}
37+
{%- if loop.index0 != 0 %}
38+
{%- set prev_idx = loop.index0 - 1 %}
39+
{%- set prev_year = rev_pages[prev_idx].components | nth(n=num_comps - 4) | int %}
40+
{%- if prev_year != year %}
41+
{{ macros::show_year(year=year, post_name="Releases") }}
42+
{%- endif %}
43+
{%- endif %}
44+
{% if page.show_year %}<tr>
45+
<td class="bn"></td>
46+
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">Posts in {{ year }}</h3></td>
47+
</tr>{% endif %}
48+
<tr>
49+
<td class="tr o-60 pr4 pr5-l bn">{{ macros::month_name(num=month) }}&nbsp;{{ day }}</td>
50+
<td class="bn"><a href="{{ config.base_url | safe }}{{ page.path | safe }}">{{ macros::escape_hbs(input=page.title) }}</a></td>
51+
</tr>
52+
{%- endif %}
53+
{%- endfor %}
54+
</table>
55+
</div>
56+
</section>
57+
{%- endblock page %}

0 commit comments

Comments
 (0)