2021-12-13 23:50:38 +00:00
|
|
|
use std::{
|
|
|
|
fs::{create_dir_all, write},
|
|
|
|
path::Path,
|
|
|
|
};
|
|
|
|
|
2021-11-26 13:08:13 +00:00
|
|
|
use askama::Template;
|
2021-12-13 23:50:38 +00:00
|
|
|
use color_eyre::Result;
|
2021-11-26 13:08:13 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Template)]
|
|
|
|
#[template(path = "index.html")]
|
|
|
|
pub struct Index {
|
|
|
|
pub page_title: String,
|
|
|
|
}
|
|
|
|
|
2021-12-13 23:50:38 +00:00
|
|
|
impl Index {
|
|
|
|
pub fn write(public_dir: &Path) -> Result<()> {
|
|
|
|
let destination = public_dir.join("index.html");
|
|
|
|
create_dir_all(destination.parent().unwrap())?;
|
|
|
|
|
|
|
|
let template = Self {
|
2022-03-28 12:59:01 +00:00
|
|
|
page_title: "Bauke".to_string(),
|
2021-12-13 23:50:38 +00:00
|
|
|
};
|
|
|
|
|
2023-01-09 14:43:05 +00:00
|
|
|
write(destination, crate::minify::html(template.render()?)?)?;
|
2021-12-13 23:50:38 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|