diff --git a/content/blog.toml b/content/_index.md similarity index 63% rename from content/blog.toml rename to content/_index.md index 889e663fb..3e926af75 100644 --- a/content/blog.toml +++ b/content/_index.md @@ -1,10 +1,11 @@ ++++ title = "Rust Blog" -index-title = "The Rust Programming Language Blog" -link-text = "the main Rust blog" +index_title = "The Rust Programming Language Blog" +link_text = "the main Rust blog" description = "Empowering everyone to build reliable and efficient software." -index-html = """ +index_html = """ This is the main Rust blog. \ Rust teams \ use this blog to announce major developments in the world of Rust.""" -maintained-by = "the Rust Teams" -requires-team = false +maintained_by = "the Rust Teams" ++++ diff --git a/content/inside-rust/blog.toml b/content/inside-rust/_index.md similarity index 74% rename from content/inside-rust/blog.toml rename to content/inside-rust/_index.md index 8014cd1f1..11ae3b7b0 100644 --- a/content/inside-rust/blog.toml +++ b/content/inside-rust/_index.md @@ -1,12 +1,13 @@ ++++ title = "Inside Rust Blog" -index-title = 'The "Inside Rust" Blog' -link-text = 'the "Inside Rust" blog' +index_title = 'The "Inside Rust" Blog' +link_text = 'the "Inside Rust" blog' description = "Want to follow along with Rust development? Curious how you might get involved? Take a look!" -index-html = """ +index_html = """ This is the "Inside Rust" blog. This blog is aimed at those who wish \ to follow along with Rust development. The various \ Rust teams and working groups \ use this blog to post status updates, calls for help, and other \ similar announcements.""" -maintained-by = "the Rust Teams" -requires-team = false +maintained_by = "the Rust Teams" ++++ diff --git a/src/blogs.rs b/src/blogs.rs index 9a06822fc..abb1f332a 100644 --- a/src/blogs.rs +++ b/src/blogs.rs @@ -2,11 +2,11 @@ use super::posts::Post; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; -static MANIFEST_FILE: &str = "blog.toml"; +static MANIFEST_FILE: &str = "_index.md"; static POSTS_EXT: &str = "md"; #[derive(Deserialize)] -#[serde(rename_all = "kebab-case", deny_unknown_fields)] +#[serde(deny_unknown_fields)] pub struct Manifest { /// Title to display in the "top row". pub(crate) title: String, @@ -23,9 +23,6 @@ pub struct Manifest { /// Raw html describing the blog to insert into the index page. pub(crate) index_html: String, - /// If true, posts require a `team` in their metadata. - pub(crate) requires_team: bool, - /// What text to use when linking to this blog in the "see also" /// section from other blogs. pub(crate) link_text: String, @@ -46,15 +43,23 @@ pub struct Blog { impl Blog { fn load(prefix: PathBuf, dir: &Path) -> eyre::Result { - let manifest_content = std::fs::read_to_string(dir.join(MANIFEST_FILE))?; + let manifest_content = std::fs::read_to_string(dir.join(MANIFEST_FILE))? + .strip_prefix("+++\n") + .unwrap() + .strip_suffix("+++\n") + .unwrap() + .to_string(); let manifest: Manifest = toml::from_str(&manifest_content)?; let mut posts = Vec::new(); for entry in std::fs::read_dir(dir)? { let path = entry?.path(); + if path.ends_with("_index.md") { + continue; // blog manifest is not a post + } let ext = path.extension().and_then(|e| e.to_str()); if path.metadata()?.file_type().is_file() && ext == Some(POSTS_EXT) { - posts.push(Post::open(&path, &manifest)?); + posts.push(Post::open(&path)?); } } @@ -115,8 +120,8 @@ impl Blog { } } -/// Recursively load blogs in a directory. A blog is a directory with a `blog.toml` -/// file inside it. +/// Recursively load blogs in a directory. A blog is a directory with a +/// `_index.md` file inside it. pub fn load(base: &Path) -> eyre::Result> { let mut blogs = Vec::new(); load_recursive(base, base, &mut blogs)?; diff --git a/src/posts.rs b/src/posts.rs index 8b7f996bf..f94d8b8e9 100644 --- a/src/posts.rs +++ b/src/posts.rs @@ -1,4 +1,3 @@ -use super::blogs::Manifest; use eyre::Context; use front_matter::FrontMatter; use regex::Regex; @@ -30,7 +29,7 @@ pub struct Post { } impl Post { - pub(crate) fn open(path: &Path, manifest: &Manifest) -> eyre::Result { + pub(crate) fn open(path: &Path) -> eyre::Result { // yeah this might blow up, but it won't let filename = { let filename = path.file_name().unwrap().to_str().unwrap().to_string(); @@ -98,11 +97,6 @@ impl Post { ), }; - // Enforce extra conditions - if manifest.requires_team && team_string.is_none() { - panic!("blog post at path `{}` lacks team metadata", path.display()); - } - // If they supplied team, it should look like `team-text ` let (team, team_url) = team_string.map_or((None, None), |s| { static R: LazyLock =