summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 26c379495e641d49debaf990f8e968779393e52c (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
25
use anyhow::Result;
use tera::{Context, Tera};

use crate::works::Works;

mod works;

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

    // render index.html file
    let context = Context::new();
    let output = tera.render("index.html", &context)?;
    std::fs::write("docs/index.html", output)?;

    // render stories.html file
    let stories = std::rc::Rc::new(works::stories::Stories::new_from_file(
        &std::fs::File::open(std::path::PathBuf::from("stories.json"))?,
    )?);
    std::rc::Rc::clone(&stories).render_overview_page(&tera, "stories")?;
    std::rc::Rc::clone(&stories).render_single_pages(&tera, "story")?;

    anyhow::Ok(())
}