Skip to content

Commit 808b149

Browse files
committed
Refactor blog manifests
- The 'requires-team' key is set to false for both blogs, so this enforcement is never active -> delete the key. - Snake case for the keys will lead to a smaller diff when migrating to zola. - Using _index.md instead of blog.toml also moves us closer to zola.
1 parent 6fd3df1 commit 808b149

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
+++
12
title = "Rust Blog"
2-
index-title = "The Rust Programming Language Blog"
3-
link-text = "the main Rust blog"
3+
index_title = "The Rust Programming Language Blog"
4+
link_text = "the main Rust blog"
45
description = "Empowering everyone to build reliable and efficient software."
5-
index-html = """
6+
index_html = """
67
This is the <b>main Rust blog</b>. \
78
<a href="https://www.rust-lang.org/governance/">Rust teams</a> \
89
use this blog to announce major developments in the world of Rust."""
9-
maintained-by = "the Rust Teams"
10-
requires-team = false
10+
maintained_by = "the Rust Teams"
11+
+++
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
+++
12
title = "Inside Rust Blog"
2-
index-title = 'The "Inside Rust" Blog'
3-
link-text = 'the "Inside Rust" blog'
3+
index_title = 'The "Inside Rust" Blog'
4+
link_text = 'the "Inside Rust" blog'
45
description = "Want to follow along with Rust development? Curious how you might get involved? Take a look!"
5-
index-html = """
6+
index_html = """
67
This is the <b>"Inside Rust"</b> blog. This blog is aimed at those who wish \
78
to follow along with Rust development. The various \
89
<a href="https://www.rust-lang.org/governance">Rust teams and working groups</a> \
910
use this blog to post status updates, calls for help, and other \
1011
similar announcements."""
11-
maintained-by = "the Rust Teams"
12-
requires-team = false
12+
maintained_by = "the Rust Teams"
13+
+++

src/blogs.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use super::posts::Post;
22
use serde::{Deserialize, Serialize};
33
use std::path::{Path, PathBuf};
44

5-
static MANIFEST_FILE: &str = "blog.toml";
5+
static MANIFEST_FILE: &str = "_index.md";
66
static POSTS_EXT: &str = "md";
77

88
#[derive(Deserialize)]
9-
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
9+
#[serde(deny_unknown_fields)]
1010
pub struct Manifest {
1111
/// Title to display in the "top row".
1212
pub(crate) title: String,
@@ -23,9 +23,6 @@ pub struct Manifest {
2323
/// Raw html describing the blog to insert into the index page.
2424
pub(crate) index_html: String,
2525

26-
/// If true, posts require a `team` in their metadata.
27-
pub(crate) requires_team: bool,
28-
2926
/// What text to use when linking to this blog in the "see also"
3027
/// section from other blogs.
3128
pub(crate) link_text: String,
@@ -54,7 +51,7 @@ impl Blog {
5451
let path = entry?.path();
5552
let ext = path.extension().and_then(|e| e.to_str());
5653
if path.metadata()?.file_type().is_file() && ext == Some(POSTS_EXT) {
57-
posts.push(Post::open(&path, &manifest)?);
54+
posts.push(Post::open(&path)?);
5855
}
5956
}
6057

@@ -119,8 +116,8 @@ impl Blog {
119116
}
120117
}
121118

122-
/// Recursively load blogs in a directory. A blog is a directory with a `blog.toml`
123-
/// file inside it.
119+
/// Recursively load blogs in a directory. A blog is a directory with a
120+
/// `_index.md` file inside it.
124121
pub fn load(base: &Path) -> eyre::Result<Vec<Blog>> {
125122
let mut blogs = Vec::new();
126123
load_recursive(base, base, &mut blogs)?;

src/posts.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use super::blogs::Manifest;
21
use eyre::Context;
32
use front_matter::FrontMatter;
43
use regex::Regex;
@@ -30,7 +29,7 @@ pub struct Post {
3029
}
3130

3231
impl Post {
33-
pub(crate) fn open(path: &Path, manifest: &Manifest) -> eyre::Result<Self> {
32+
pub(crate) fn open(path: &Path) -> eyre::Result<Self> {
3433
// yeah this might blow up, but it won't
3534
let filename = {
3635
let filename = path.file_name().unwrap().to_str().unwrap().to_string();
@@ -98,11 +97,6 @@ impl Post {
9897
),
9998
};
10099

101-
// Enforce extra conditions
102-
if manifest.requires_team && team_string.is_none() {
103-
panic!("blog post at path `{}` lacks team metadata", path.display());
104-
}
105-
106100
// If they supplied team, it should look like `team-text <team-url>`
107101
let (team, team_url) = team_string.map_or((None, None), |s| {
108102
static R: LazyLock<Regex> =

0 commit comments

Comments
 (0)