aboutsummaryrefslogtreecommitdiff
path: root/code/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'code/src/main.rs')
-rw-r--r--code/src/main.rs13
1 files changed, 7 insertions, 6 deletions
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()
+ ))),
)
}