Creating a SiteRenderer struct to handle the logic for invoking dust.
This commit is contained in:
21
src/command/build/render.rs
Normal file
21
src/command/build/render.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::blog_post::convert_blog_post_to_render_context;
|
||||
use crate::blog_post::BlogPost;
|
||||
use crate::error::CustomError;
|
||||
|
||||
pub(crate) struct SiteRenderer {
|
||||
pub(crate) output_directory: PathBuf,
|
||||
pub(crate) blog_posts: Vec<BlogPost>,
|
||||
}
|
||||
|
||||
impl SiteRenderer {
|
||||
pub(crate) async fn render_blog_posts(&self) -> Result<(), CustomError> {
|
||||
for blog_post in &self.blog_posts {
|
||||
let render_context = convert_blog_post_to_render_context(blog_post);
|
||||
println!("{}", serde_json::to_string(&render_context)?);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user