Convert intermediate objects into render objects.
This commit is contained in:
@@ -1,10 +1,36 @@
|
||||
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<RenderObject>,
|
||||
}
|
||||
|
||||
impl RenderHeading {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
heading: &Heading,
|
||||
) -> Result<RenderHeading, CustomError> {
|
||||
let title = heading
|
||||
.title
|
||||
.iter()
|
||||
.map(|obj| RenderObject::new(config, &output_directory, &output_file, obj))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(RenderHeading {
|
||||
level: heading.level,
|
||||
title,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::blog_post::Object;
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum RenderObject {}
|
||||
|
||||
impl RenderObject {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
section: &Object,
|
||||
) -> Result<RenderObject, CustomError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user