//! The main [`askama`] templates. use std::{ fs::{create_dir_all, write}, path::Path, }; use askama::Template; use color_eyre::Result; /// The template for the home page. #[derive(Debug, Template)] #[template(path = "index.html")] pub struct Index { /// The text for the `` element. pub page_title: String, } impl Index { /// Build, minify and write the template. pub fn write(public_dir: &Path) -> Result<()> { let destination = public_dir.join("index.html"); create_dir_all(destination.parent().unwrap())?; let template = Self { page_title: "Bauke".to_string(), }; write(destination, crate::minify::html(template.render()?)?)?; Ok(()) } }