From 0e9af4f540cf974bc2038f00c5528441f42b9760 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Wed, 30 Aug 2023 19:15:11 +0200 Subject: [PATCH] Switched front-matter from TOML to YAML as that makes a bit more sense --- markdown/project/automation.md | 6 +++--- markdown/project/car-stereo.md | 6 +++--- markdown/project/pico_p1.md | 6 +++--- markdown/project/z80.md | 6 +++--- tool/Cargo.lock | 26 ++++++++++++++++---------- tool/Cargo.toml | 2 +- tool/src/main.rs | 8 ++++---- 7 files changed, 33 insertions(+), 27 deletions(-) diff --git a/markdown/project/automation.md b/markdown/project/automation.md index b1e4bdd..7caec11 100644 --- a/markdown/project/automation.md +++ b/markdown/project/automation.md @@ -1,7 +1,7 @@ --- -type = "Project" -url = "git.huizinga.dev/Dreaded_X/automation_rs" -title = "Home Automation" +project: + url: git.huizinga.dev/Dreaded_X/automation_rs + title: Home Automation --- I have slowly been converting my house into my very own smart home! diff --git a/markdown/project/car-stereo.md b/markdown/project/car-stereo.md index c8eef7e..d5cd9bf 100644 --- a/markdown/project/car-stereo.md +++ b/markdown/project/car-stereo.md @@ -1,7 +1,7 @@ --- -type = "Project" -url = "git.huizinga.dev/Dreaded_X/car-stereo" -title = "Car Stereo" +project: + url: git.huizinga.dev/Dreaded_X/car-stereo + title: Car Stereo --- My Peugeot 207 only has bluetooth for calling, so I decided it would be fun to build my own bluetooth receiver using the [ESP32] microcontroller. diff --git a/markdown/project/pico_p1.md b/markdown/project/pico_p1.md index 6ac2f07..4f01074 100644 --- a/markdown/project/pico_p1.md +++ b/markdown/project/pico_p1.md @@ -1,7 +1,7 @@ --- -type = "Project" -url = "git.huizinga.dev/Dreaded_X/pico_p1" -title = "Pico P1" +project: + url: git.huizinga.dev/Dreaded_X/pico_p1 + title: Pico P1 --- This is my most recent project, as I had recently decided to pick up a [Raspberry Pi Pico W] just to play around with. diff --git a/markdown/project/z80.md b/markdown/project/z80.md index e2a43fb..1d6b277 100644 --- a/markdown/project/z80.md +++ b/markdown/project/z80.md @@ -1,7 +1,7 @@ --- -type = "Project" -url = "git.huizinga.dev/Z80/Z80" -title = "Z80 Computer" +project: + url: git.huizinga.dev/Z80/Z80 + title: Z80 Computer --- The first big hardware project that I worked on was building a computer, from the ground up, around the [Z80] microprocessor. diff --git a/tool/Cargo.lock b/tool/Cargo.lock index c95a376..ee52545 100644 --- a/tool/Cargo.lock +++ b/tool/Cargo.lock @@ -31,7 +31,7 @@ checksum = "1cf2fb99fac0b821a4e61c61abff076324bb0e5c3b4a83815bbc3518a38971ad" dependencies = [ "serde", "serde_json", - "toml", + "yaml-rust", ] [[package]] @@ -40,6 +40,12 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "memchr" version = "2.6.1" @@ -150,15 +156,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "tool" version = "0.1.0" @@ -217,3 +214,12 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] diff --git a/tool/Cargo.toml b/tool/Cargo.toml index db0b492..acefaff 100644 --- a/tool/Cargo.toml +++ b/tool/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0.75" dotenvy = "0.15.7" gray_matter = { version = "0.2.6", features = [ - "toml", + "yaml", ], default-features = false } regex = "1.9.4" serde = { version = "1.0.188", features = ["derive"] } diff --git a/tool/src/main.rs b/tool/src/main.rs index 78fcf25..81ee5ea 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -4,13 +4,13 @@ use std::{ path::Path, }; -use gray_matter::{engine::TOML, Matter}; +use gray_matter::{engine::YAML, Matter}; use regex::{Captures, Regex}; use serde::Deserialize; use walkdir::WalkDir; #[derive(Debug, Deserialize)] -#[serde(tag = "type")] +#[serde(rename_all = "snake_case")] enum FrontMatter { Project { title: String, url: String }, } @@ -26,7 +26,7 @@ fn main() -> anyhow::Result<()> { } fn generate_latex() -> anyhow::Result<()> { - let matter = Matter::::new(); + let matter = Matter::::new(); let prefix = Path::new("../markdown"); @@ -88,7 +88,7 @@ fn generate_readme() -> anyhow::Result<()> { let mut contents = String::new(); file.read_to_string(&mut contents)?; - let matter = Matter::::new(); + let matter = Matter::::new(); let re = Regex::new(r"\#\{(.*)\}").expect("Regex should be valid"); let contents = re.replace_all(&contents, |caps: &Captures| {