use std::path::Path; use serde::Serialize; use crate::blog_post::Heading; use crate::config::Config; use crate::error::CustomError; use super::RenderObject; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "heading")] pub(crate) struct RenderHeading { level: organic::types::HeadlineLevel, title: Vec, } impl RenderHeading { pub(crate) fn new, F: AsRef>( config: &Config, output_directory: D, output_file: F, heading: &Heading, ) -> Result { let title = heading .title .iter() .map(|obj| RenderObject::new(config, &output_directory, &output_file, obj)) .collect::, _>>()?; Ok(RenderHeading { level: heading.level, title, }) } }