summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 4af487e98613cedfa00dbd25d603426c3db4a3db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use anyhow::Result;
use tera::{Context, Tera};

use crate::works::Works;

mod works;

fn main() -> Result<()> {
    let tera = Tera::new("templates/**/*.html")?;

    let context = Context::new();

    let output = tera.render("index.html", &context)?;

    std::fs::write("docs/index.html", output)?;

    let file = std::fs::File::open(std::path::PathBuf::from("stories.json"))?;
    let stories = works::stories::Stories::new_from_file(file);
    let context = stories?.create_tera_context();

    let stories_html_output = tera.render("stories.html", &context?)?;
    std::fs::write("docs/stories.html", stories_html_output)?;
    Ok(())
}