From a4dd9c4944340505962f07853d53ab02f3a02336 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 29 Aug 2022 18:04:17 +0200 Subject: set title --- code/src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'code/src/main.rs') diff --git a/code/src/main.rs b/code/src/main.rs index 6e281df..d90139e 100644 --- a/code/src/main.rs +++ b/code/src/main.rs @@ -26,9 +26,8 @@ fn main() { let args = Args::parse(); match args.action { ArgAction::RenderArticle { input } => { - let md_source = read_to_string(input).unwrap(); let mut out = Buffer::new(); - article(md_source).render(&mut out); + article(input).render(&mut out); write_output(&args.output, out.into_string()); } ArgAction::RenderIndex { root } => { @@ -52,7 +51,7 @@ fn scaffold(title: String, body: impl Render) -> impl Render { html!( head!( link!(rel = "stylesheet", href = "./style.css"), - title!(title) + title!(format!("{} - metamuffin's blog", title)) ), body!( nav!(h2!("metamuffin's blog"), a!(href = "./index.html", "index")), @@ -88,10 +87,12 @@ fn article_title(path: PathBuf) -> String { String::from(&buf[2..]) } -fn article(md_source: String) -> impl Render { +fn article(path: String) -> impl Render { scaffold( - "blub".to_string(), - raw!(blocks_to_html(markdown::tokenize(&md_source))), + article_title(path.clone().into()), + raw!(blocks_to_html(markdown::tokenize( + &read_to_string(path).unwrap() + ))), ) } -- cgit v1.2.3-70-g09d2