Skip to content

Commit 295b875

Browse files
committed
fix(website): 🐛 fixed links in docs version warnings
1 parent d676471 commit 295b875

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

website/website/src/templates/docs/generation.rs

+13-24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use crate::templates::docs::icons::{ERROR_ICON, WARNING_ICON};
22
use crate::templates::docs::template::DocsPageProps;
33
use lazy_static::lazy_static;
4-
use perseus::{
5-
link, path_prefix::get_path_prefix_server, t, RenderFnResult, RenderFnResultWithCause,
6-
};
4+
use perseus::{path_prefix::get_path_prefix_server, t, RenderFnResult, RenderFnResultWithCause};
75
use pulldown_cmark::{html, Options, Parser};
86
use serde::{Deserialize, Serialize};
97
use std::fs;
@@ -38,20 +36,19 @@ pub enum DocsVersionStatus {
3836
/// This version is stable, and no warning is needed.
3937
Stable,
4038
/// This version is outdated, and the latest stable version is attached.
41-
Outdated(String),
39+
Outdated,
4240
/// This version is released, but in beta, and the latest stable version is attached.
43-
Beta(String),
41+
Beta,
4442
/// This documentation is for the unreleased next version, and the latest stable version is attached.
45-
Next(String),
43+
Next,
4644
}
4745
impl DocsVersionStatus {
4846
/// Renders the docs status to a Sycamore template for display.
4947
pub fn render<G: GenericNode>(&self) -> SycamoreTemplate<G> {
5048
match &self {
5149
// No message should be displayed if it's the correct version
5250
Self::Stable => template! {},
53-
Self::Outdated(stable) => {
54-
let stable = stable.to_string();
51+
Self::Outdated => {
5552
template! {
5653
div(class = "ring-4 ring-red-400 p-4 rounded-lg mt-1") {
5754
div(class = "flex flex-col 2xs:flex-row dark:text-white") {
@@ -60,15 +57,12 @@ impl DocsVersionStatus {
6057
style = "fill: #f87171;",
6158
dangerously_set_inner_html = ERROR_ICON
6259
)
63-
p(dangerously_set_inner_html = &t!("docs-status.outdated", {
64-
"link": link!(&format!("/docs/{}/intro", stable))
65-
}))
60+
p(dangerously_set_inner_html = &t!("docs-status.outdated"))
6661
}
6762
}
6863
}
6964
}
70-
Self::Beta(stable) => {
71-
let stable = stable.to_string();
65+
Self::Beta => {
7266
template! {
7367
div(class = "ring-4 ring-yellow-300 p-4 rounded-lg mt-1") {
7468
div(class = "flex flex-col 2xs:flex-row dark:text-white") {
@@ -77,15 +71,12 @@ impl DocsVersionStatus {
7771
style = "fill: #fcd34d;",
7872
dangerously_set_inner_html = WARNING_ICON
7973
)
80-
p(dangerously_set_inner_html = &t!("docs-status.beta", {
81-
"link": link!(&format!("/docs/{}/intro", stable))
82-
}))
74+
p(dangerously_set_inner_html = &t!("docs-status.beta"))
8375
}
8476
}
8577
}
8678
}
87-
Self::Next(stable) => {
88-
let stable = stable.to_string();
79+
Self::Next => {
8980
template! {
9081
div(class = "ring-4 ring-orange-400 p-4 rounded-lg mt-1") {
9182
div(class = "flex flex-col 2xs:flex-row dark:text-white") {
@@ -94,9 +85,7 @@ impl DocsVersionStatus {
9485
style = "fill: #fb923c;",
9586
dangerously_set_inner_html = ERROR_ICON
9687
)
97-
p(dangerously_set_inner_html = &t!("docs-status.next", {
98-
"link": link!(&format!("/docs/{}/intro", stable))
99-
}))
88+
p(dangerously_set_inner_html = &t!("docs-status.next"))
10089
}
10190
}
10291
}
@@ -243,11 +232,11 @@ pub async fn get_build_state(path: String, locale: String) -> RenderFnResultWith
243232

244233
// Work out the status of this page
245234
let status = if version == "next" {
246-
DocsVersionStatus::Next(DOCS_MANIFEST.stable.to_string())
235+
DocsVersionStatus::Next
247236
} else if DOCS_MANIFEST.outdated.contains(&version.to_string()) {
248-
DocsVersionStatus::Outdated(DOCS_MANIFEST.stable.to_string())
237+
DocsVersionStatus::Outdated
249238
} else if DOCS_MANIFEST.beta.contains(&version.to_string()) {
250-
DocsVersionStatus::Beta(DOCS_MANIFEST.stable.to_string())
239+
DocsVersionStatus::Beta
251240
} else if DOCS_MANIFEST.stable == version {
252241
DocsVersionStatus::Stable
253242
} else {

website/website/translations/en-US.ftl

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This will need to be updated for warning links
2+
-latest-stable-version = 0.2.x
3+
14
perseus = Perseus
25
sycamore = Sycamore
36
navlinks-docs = Docs
@@ -90,9 +93,9 @@ comparisons-table-details =
9093
9194
docs-title-base = Perseus Docs
9295
docs-status =
93-
.outdated = This version of the documentation is outdated, and features documented here may work differently now. You can see the latest stable version of the docs <a href="{ $link }" class="underline">here</a>.
94-
.beta = This version of the documentation is for a version that has only been released in beta, and is not yet stable. Features documented here may not be present in the latest stable version, and they're subject to rapid and drastic change. You can see the latest stable version of the docs <a href="{ $link }" class="underline">here</a>.
95-
.next = This version of the documentation is for a version that has not yet been released, and features documented here may not be present in the latest release. You can see the latest stable version of the docs <a href="{ $link }" class="underline">here</a>.
96+
.outdated = This version of the documentation is outdated, and features documented here may work differently now. You can see the latest stable version of the docs <a href="en-US/docs/{ -latest-stable-version }/intro" class="underline">here</a>.
97+
.beta = This version of the documentation is for a version that has only been released in beta, and is not yet stable. Features documented here may not be present in the latest stable version, and they're subject to rapid and drastic change. You can see the latest stable version of the docs <a href="en-US/docs/{ -latest-stable-version }/intro" class="underline">here</a>.
98+
.next = This version of the documentation is for a version that has not yet been released, and features documented here may not be present in the latest release. You can see the latest stable version of the docs <a href="en-US/docs/{ -latest-stable-version }/intro" class="underline">here</a>.
9699
docs-version-switcher =
97100
.next = Next (unreleased)
98101
.beta = v{ $version } (beta)

0 commit comments

Comments
 (0)