Skip to content

Commit 4b0bd04

Browse files
authored
Merge pull request #1586 from rust-lang/senekor/qkkxqmsxwvot
Fix front matter validation for posts with colocated assets
2 parents cbeb36c + 4288851 commit 4b0bd04

File tree

7 files changed

+33
-12
lines changed

7 files changed

+33
-12
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

content/Rust-1.12/index.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
path = "2016/09/29/Rust-1.12"
33
title = "Announcing Rust 1.12"
44
authors = ["The Rust Core Team"]
5-
aliases = ["2016/09/29/Rust-1.12.html"]
5+
aliases = [
6+
"2016/09/29/Rust-1.12.html",
7+
"releases/1.12.0",
8+
]
69

710
[extra]
811
release = true

content/Rust-1.13/index.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
path = "2016/11/10/Rust-1.13"
33
title = "Announcing Rust 1.13"
44
authors = ["The Rust Core Team"]
5-
aliases = ["2016/11/10/Rust-1.13.html"]
5+
aliases = [
6+
"2016/11/10/Rust-1.13.html",
7+
"releases/1.13.0",
8+
]
69

710
[extra]
811
release = true

content/Rust-1.30.0/index.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
path = "2018/10/25/Rust-1.30.0"
33
title = "Announcing Rust 1.30"
44
authors = ["The Rust Core Team"]
5-
aliases = ["2018/10/25/Rust-1.30.0.html"]
5+
aliases = [
6+
"2018/10/25/Rust-1.30.0.html",
7+
"releases/1.30.0",
8+
]
69

710
[extra]
811
release = true

content/Rust-1.60.0/index.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
path = "2022/04/07/Rust-1.60.0"
33
title = "Announcing Rust 1.60.0"
44
authors = ["The Rust Release Team"]
5-
aliases = ["2022/04/07/Rust-1.60.0.html"]
5+
aliases = [
6+
"2022/04/07/Rust-1.60.0.html",
7+
"releases/1.60.0",
8+
]
69

710
[extra]
811
release = true

front_matter/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ edition = "2024"
77
eyre = "=0.6.12"
88
serde = { version = "=1.0.219", features = ["derive"] }
99
toml = "=0.8.20"
10+
11+
[dev-dependencies]
12+
walkdir = "2.5.0"

front_matter/src/lib.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ mod tests {
175175
.contains("content/inside-rust/");
176176

177177
let content = fs::read_to_string(&post).unwrap();
178-
let (front_matter, rest) = parse(&content).unwrap();
178+
let (front_matter, rest) = parse(&content).unwrap_or_else(|err| {
179+
panic!("failed to parse {:?}: {err}", post.display());
180+
});
179181
let normalized = normalize(&front_matter, slug, inside_rust).unwrap_or_else(|err| {
180-
panic!("failed to normalize {:?}: {err}", post.file_name().unwrap());
182+
panic!("failed to normalize {:?}: {err}", post.display());
181183
});
182184

183185
if front_matter != normalized {
@@ -253,11 +255,14 @@ The post {post} has abnormal front matter.
253255
}
254256

255257
fn all_posts() -> impl Iterator<Item = PathBuf> {
256-
let repo_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("..");
257-
fs::read_dir(repo_root.join("content"))
258-
.unwrap()
259-
.chain(fs::read_dir(repo_root.join("content/inside-rust")).unwrap())
260-
.map(|p| p.unwrap().path())
261-
.filter(|p| p.is_file() && p.file_name() != Some("_index.md".as_ref()))
258+
walkdir::WalkDir::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../content"))
259+
.into_iter()
260+
.filter_map(|e| e.ok().map(|e| e.into_path()))
261+
.filter(|p| {
262+
p.is_file()
263+
&& p.extension() == Some("md".as_ref())
264+
&& p.file_name() != Some("_index.md".as_ref())
265+
&& p.file_name() != Some("latest.md".as_ref())
266+
})
262267
}
263268
}

0 commit comments

Comments
 (0)