diff --git a/website/templates/header.html b/website/templates/header.html index c5070b0..9f0511f 100644 --- a/website/templates/header.html +++ b/website/templates/header.html @@ -1,6 +1,3 @@ -{% set docs_info = load_data(path="content/docs/info.toml") %} -{% set latest = docs_info["latest"] %} -
- + \ No newline at end of file diff --git a/website/templates/index.html b/website/templates/index.html index 4392bd8..490a9d9 100644 --- a/website/templates/index.html +++ b/website/templates/index.html @@ -13,16 +13,10 @@
- About - Guide + About + Guide
@@ -33,4 +27,4 @@
-{% endblock content %} +{% endblock content %} \ No newline at end of file diff --git a/website/xtask/src/convert_docs.rs b/website/xtask/src/convert_docs.rs index 3bf48a4..9096c98 100644 --- a/website/xtask/src/convert_docs.rs +++ b/website/xtask/src/convert_docs.rs @@ -8,8 +8,6 @@ use std::{ path::{Path, PathBuf}, }; -use crate::docs_info::DocsInfo; - pub fn run() -> Result<()> { convert_single_page_doc( "about.md", @@ -21,7 +19,7 @@ insert_anchor_links = "heading" "#, true, false, - FixUrlMode::TopLevelToLatest, + FixUrlMode::TopLevelToNext, )?; convert_single_page_doc( "language_guide.md", @@ -172,8 +170,8 @@ struct ConvertDocFlags { #[derive(Copy, Clone)] enum FixUrlMode { - // Adjust doc links to docs/latest - TopLevelToLatest, + // Adjust doc links to docs/next + TopLevelToNext, // Adjust doc links to neighboring docs version TopLevel, // Adjust doc links to neighboring docs version from docs subfolder @@ -323,14 +321,11 @@ fn fix_doc_urls(url: &str, mode: FixUrlMode) -> Result { use FixUrlMode::*; let result = match mode { - TopLevelToLatest => { - let docs_info = DocsInfo::get_info(); - let latest = &docs_info.latest; - url.replace("./language_guide.md", &format!("/docs/{latest}/language/")) - .replace("./cli.md", &format!("/docs/{latest}/cli/")) - .replace("./api.md", &format!("/docs/{latest}/api/")) - .replace("./core_lib", &format!("/docs/{latest}/core/")) - } + TopLevelToNext => url + .replace("./language_guide.md", &format!("/docs/next/language/")) + .replace("./cli.md", &format!("/docs/next/cli/")) + .replace("./api.md", &format!("/docs/next/api/")) + .replace("./core_lib", &format!("/docs/next/core/")), TopLevel => url .replace("./core_lib", "../core") .replace("./language_guide.md", "../language/"), diff --git a/website/xtask/src/docs_info.rs b/website/xtask/src/docs_info.rs index 5bbac3e..3bf5bc9 100644 --- a/website/xtask/src/docs_info.rs +++ b/website/xtask/src/docs_info.rs @@ -4,13 +4,3 @@ use serde::{Deserialize, Serialize}; pub struct DocsInfo { pub latest: String, } - -impl DocsInfo { - pub fn get_info() -> Self { - let info = include_str!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/../content/docs/info.toml" - )); - toml::from_str(info).unwrap() - } -} diff --git a/website/xtask/src/postprocess_playground.rs b/website/xtask/src/postprocess_playground.rs index b5f2336..0fac97b 100644 --- a/website/xtask/src/postprocess_playground.rs +++ b/website/xtask/src/postprocess_playground.rs @@ -1,13 +1,14 @@ use anyhow::{Context, Result}; use std::{fs, io::Write, path::PathBuf}; -use crate::docs_info::DocsInfo; - pub fn run(staging_dir: &str) -> Result<()> { let index_path: PathBuf = [staging_dir, "index.html"].iter().collect(); let index = fs::read_to_string(&index_path).context("Failed to read index.html")?; - let header = get_header()?; + let header = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../templates/header.html" + )); let mobile_nav = concat!( include_str!(concat!( env!("CARGO_MANIFEST_DIR"), @@ -32,21 +33,3 @@ pub fn run(staging_dir: &str) -> Result<()> { Ok(()) } - -fn get_header() -> Result { - // The header is a Zola template, but the playground isn't rendered with Zola, - // so it needs to be patched manually. - let header_template = include_str!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/../templates/header.html" - )); - let latest = DocsInfo::get_info().latest; - let mut result = String::with_capacity(header_template.len()); - for line in header_template.lines() { - if line.starts_with("{%") { - continue; - } - result.push_str(&line.replace(r"{{latest}}", &latest)); - } - Ok(result) -}