Skip to content

Add /releases page #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ This is the <b>main Rust blog</b>. \
<a href="https://www.rust-lang.org/governance/">Rust teams</a> \
use this blog to announce major developments in the world of Rust."""
maintained_by = "the Rust Teams"
see_also_path = "/inside-rust/"
see_also_text = """the "Inside Rust" blog"""
[[extra.see_also]]
path = "/inside-rust/"
text = """the "Inside Rust" blog"""
[[extra.see_also]]
path = "/releases/"
text = "release announcements"
+++
5 changes: 3 additions & 2 deletions content/inside-rust/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ to follow along with Rust development. The various \
use this blog to post status updates, calls for help, and other \
similar announcements."""
maintained_by = "the Rust Teams"
see_also_path = "/"
see_also_text = "the main Rust blog"
[[extra.see_also]]
path = "/"
text = "the main Rust blog"
+++
6 changes: 6 additions & 0 deletions content/releases/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+++
title = "Rust Release Announcements"
template = "releases.html"
[extra]
index_title = "The Rust Release Announcements"
+++
3 changes: 3 additions & 0 deletions content/releases/latest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
+++
template = "latest.html"
+++
5 changes: 4 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
<div class="mw8-l">
<p>
<b>See also:</b>
<a href="{{ config.base_url | safe }}{{ section.extra.see_also_path | safe }}">{{ section.extra.see_also_text }}</a>
{% for see_also in section.extra.see_also -%}
{% if loop.index0 != 0 %},{% endif %}
<a href="{{ config.base_url | safe }}{{ see_also.path | safe }}">{{ see_also.text }}</a>
{%- endfor -%}
</p>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions templates/latest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% set section = get_section(path="_index.md") -%}
{%- for page in section.pages | reverse -%}{% if page.extra is containing("release") -%}
<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirect</title>
<meta http-equiv="refresh" content="0; url={{ page.path | safe }}">
<p><a href="{{ page.path | safe }}">Click here</a> to be redirected to the latest Rust release annoucement.</p>
{% break %}{% endif %}{% endfor -%}
4 changes: 2 additions & 2 deletions templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
}}
{%- endmacro escape_hbs %}

{% macro show_year(year) -%}
{% macro show_year(year, post_name="Posts") -%}
<tr>
<td class="bn"></td>
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">Posts in {{ year }}</h3></td>
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">{{ post_name }} in {{ year }}</h3></td>
</tr>
{%- endmacro show_year %}
57 changes: 57 additions & 0 deletions templates/releases.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{% import "macros.html" as macros -%}
{% extends "layout.html" -%}
{% block page -%}
<header class="mt3 mt0-ns mb4-ns">
<div class="container flex flex-column flex-row-l justify-between-l">
<div class="mw6-l">
<p>
This is a subset of the <a href="/">main Rust blog</a>
listing only official release annoucement posts.
</p>
<p>
Did you know? There are convenient redirects for
the latest and specific release posts:
<br/>• <a href="/releases/latest">/releases/latest</a>
<br/>• <a href="/releases/1.85.0">/releases/1.85.0</a>
</p>
</div>
</div>
</header>

{% set section = get_section(path="_index.md") -%}
<section id="posts" class="posts">
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">

<table class="post-list collapse w-100 f2-l f2-m f3-s">
{%- set rev_pages = section.pages | reverse %}
{%- for page in rev_pages %}
{%- set num_comps = page.components | length %}
{%- set year = page.components | nth(n=num_comps - 4) | int %}
{%- set month = page.components | nth(n=num_comps - 3) | int %}
{%- set day = page.components | nth(n=num_comps - 2) | int %}
{%- if loop.index0 == 0 %}
{{ macros::show_year(year=year, post_name="Releases") }}
{%- endif %}

{%- if page.extra is containing("release") %}
{%- if loop.index0 != 0 %}
{%- set prev_idx = loop.index0 - 1 %}
{%- set prev_year = rev_pages[prev_idx].components | nth(n=num_comps - 4) | int %}
{%- if prev_year != year %}
{{ macros::show_year(year=year, post_name="Releases") }}
{%- endif %}
{%- endif %}
{% if page.show_year %}<tr>
<td class="bn"></td>
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">Posts in {{ year }}</h3></td>
</tr>{% endif %}
<tr>
<td class="tr o-60 pr4 pr5-l bn">{{ macros::month_name(num=month) }}&nbsp;{{ day }}</td>
<td class="bn"><a href="{{ config.base_url | safe }}{{ page.path | safe }}">{{ macros::escape_hbs(input=page.title) }}</a></td>
</tr>
{%- endif %}
{%- endfor %}
</table>
</div>
</section>
{%- endblock page %}