Blog/src/lib.rs

26 lines
552 B
Rust
Raw Normal View History

2023-08-27 20:17:16 -05:00
use tera::Tera;
pub mod markdown;
pub mod page_gen;
pub mod syntax;
2023-08-27 20:17:16 -05:00
pub trait TemplateRenderer {
fn render_template(&self, tera: &Tera) -> anyhow::Result<String>;
}
pub fn iter_dir<F>(path: &std::path::PathBuf, phandler: &F) -> anyhow::Result<()>
where
F: Fn(&std::fs::DirEntry) -> anyhow::Result<()>,
{
for item in std::fs::read_dir(path)? {
let entry = item?;
if entry.file_type()?.is_dir() {
iter_dir(&entry.path(), phandler)?;
} else {
phandler(&entry)?;
}
}
Ok(())
}