Switched front-matter from TOML to YAML as that makes a bit more sense

This commit is contained in:
Dreaded_X 2023-08-30 19:15:11 +02:00
parent 8f554e5c2e
commit 0e9af4f540
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
7 changed files with 33 additions and 27 deletions

View File

@ -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!

View File

@ -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.

View File

@ -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.

View File

@ -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.

26
tool/Cargo.lock generated
View File

@ -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",
]

View File

@ -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"] }

View File

@ -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::<TOML>::new();
let matter = Matter::<YAML>::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::<TOML>::new();
let matter = Matter::<YAML>::new();
let re = Regex::new(r"\#\{(.*)\}").expect("Regex should be valid");
let contents = re.replace_all(&contents, |caps: &Captures| {