diff --git a/Cargo.lock b/Cargo.lock index 550c21469..fb89ce2e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,6 +62,7 @@ dependencies = [ "eyre", "serde", "toml", + "walkdir", ] [[package]] diff --git a/content/Rust-1.12/index.md b/content/Rust-1.12/index.md index 4870fff60..549e16abd 100644 --- a/content/Rust-1.12/index.md +++ b/content/Rust-1.12/index.md @@ -2,7 +2,10 @@ path = "2016/09/29/Rust-1.12" title = "Announcing Rust 1.12" authors = ["The Rust Core Team"] -aliases = ["2016/09/29/Rust-1.12.html"] +aliases = [ + "2016/09/29/Rust-1.12.html", + "releases/1.12.0", +] [extra] release = true diff --git a/content/Rust-1.13/index.md b/content/Rust-1.13/index.md index 42afc59cb..ea9175e04 100644 --- a/content/Rust-1.13/index.md +++ b/content/Rust-1.13/index.md @@ -2,7 +2,10 @@ path = "2016/11/10/Rust-1.13" title = "Announcing Rust 1.13" authors = ["The Rust Core Team"] -aliases = ["2016/11/10/Rust-1.13.html"] +aliases = [ + "2016/11/10/Rust-1.13.html", + "releases/1.13.0", +] [extra] release = true diff --git a/content/Rust-1.30.0/index.md b/content/Rust-1.30.0/index.md index 5d89e50ec..daaae637b 100644 --- a/content/Rust-1.30.0/index.md +++ b/content/Rust-1.30.0/index.md @@ -2,7 +2,10 @@ path = "2018/10/25/Rust-1.30.0" title = "Announcing Rust 1.30" authors = ["The Rust Core Team"] -aliases = ["2018/10/25/Rust-1.30.0.html"] +aliases = [ + "2018/10/25/Rust-1.30.0.html", + "releases/1.30.0", +] [extra] release = true diff --git a/content/Rust-1.60.0/index.md b/content/Rust-1.60.0/index.md index 63b3dc8d3..8485c37ed 100644 --- a/content/Rust-1.60.0/index.md +++ b/content/Rust-1.60.0/index.md @@ -2,7 +2,10 @@ path = "2022/04/07/Rust-1.60.0" title = "Announcing Rust 1.60.0" authors = ["The Rust Release Team"] -aliases = ["2022/04/07/Rust-1.60.0.html"] +aliases = [ + "2022/04/07/Rust-1.60.0.html", + "releases/1.60.0", +] [extra] release = true diff --git a/front_matter/Cargo.toml b/front_matter/Cargo.toml index 93120b784..4337313e7 100644 --- a/front_matter/Cargo.toml +++ b/front_matter/Cargo.toml @@ -7,3 +7,6 @@ edition = "2024" eyre = "=0.6.12" serde = { version = "=1.0.219", features = ["derive"] } toml = "=0.8.20" + +[dev-dependencies] +walkdir = "2.5.0" diff --git a/front_matter/src/lib.rs b/front_matter/src/lib.rs index 9a4798efe..aba00fd10 100644 --- a/front_matter/src/lib.rs +++ b/front_matter/src/lib.rs @@ -175,9 +175,11 @@ mod tests { .contains("content/inside-rust/"); let content = fs::read_to_string(&post).unwrap(); - let (front_matter, rest) = parse(&content).unwrap(); + let (front_matter, rest) = parse(&content).unwrap_or_else(|err| { + panic!("failed to parse {:?}: {err}", post.display()); + }); let normalized = normalize(&front_matter, slug, inside_rust).unwrap_or_else(|err| { - panic!("failed to normalize {:?}: {err}", post.file_name().unwrap()); + panic!("failed to normalize {:?}: {err}", post.display()); }); if front_matter != normalized { @@ -253,11 +255,14 @@ The post {post} has abnormal front matter. } fn all_posts() -> impl Iterator { - let repo_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(".."); - fs::read_dir(repo_root.join("content")) - .unwrap() - .chain(fs::read_dir(repo_root.join("content/inside-rust")).unwrap()) - .map(|p| p.unwrap().path()) - .filter(|p| p.is_file() && p.file_name() != Some("_index.md".as_ref())) + walkdir::WalkDir::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../content")) + .into_iter() + .filter_map(|e| e.ok().map(|e| e.into_path())) + .filter(|p| { + p.is_file() + && p.extension() == Some("md".as_ref()) + && p.file_name() != Some("_index.md".as_ref()) + && p.file_name() != Some("latest.md".as_ref()) + }) } }