Introduce a registry into the conversion to intermediate format.

This commit is contained in:
Tom Alexander
2023-10-27 14:43:06 -04:00
parent e3b5f7f74f
commit c6cf5f75ac
8 changed files with 68 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ use std::path::PathBuf;
use crate::error::CustomError;
use super::registry::Registry;
use super::IDocumentElement;
use super::IHeading;
use super::ISection;
@@ -19,15 +20,16 @@ pub(crate) struct BlogPostPage {
impl BlogPostPage {
pub(crate) fn new<P: Into<PathBuf>>(
path: P,
document: organic::types::Document<'_>,
registry: &mut Registry<'_>,
document: &organic::types::Document<'_>,
) -> Result<BlogPostPage, CustomError> {
let path = path.into();
let mut children = Vec::new();
if let Some(section) = document.zeroth_section.as_ref() {
children.push(IDocumentElement::Section(ISection::new(section)?));
children.push(IDocumentElement::Section(ISection::new(registry, section)?));
}
for heading in document.children.iter() {
children.push(IDocumentElement::Heading(IHeading::new(heading)?));
children.push(IDocumentElement::Heading(IHeading::new(registry, heading)?));
}
Ok(BlogPostPage {