]> git.r.bdr.sh - rbdr/blog/blame_incremental - src/generator/mod.rs
Add release
[rbdr/blog] / src / generator / mod.rs
... / ...
CommitLineData
1mod static_files;
2mod html;
3mod rss;
4mod txt;
5
6use std::io::Result;
7use std::path::PathBuf;
8use crate::post::Post;
9use crate::template::TemplateContext;
10
11pub fn generate(static_directory: &PathBuf, template_directory: &PathBuf, output_directory: &PathBuf, posts: &Vec<Post>) -> Result<()> {
12 let generators = available_generators();
13 let context = Post::to_template_context(&posts);
14 for generator in generators {
15 generator(static_directory, template_directory, output_directory, &context)?;
16 }
17 Ok(())
18}
19
20
21fn available_generators() -> Vec<fn(&PathBuf, &PathBuf, &PathBuf, &TemplateContext) -> Result<()>> {
22 vec![
23 static_files::generate,
24 // These three are actually the same. Can generalize, don't know how in rust yet.
25 html::generate,
26 rss::generate,
27 txt::generate
28 ]
29}