diff --git a/src/main.rs b/src/main.rs index 1c9d879..59a1820 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ struct Frontmatter { } // The struct representing the page, as constructed from the frontmatter -#[derive(Clone, Serialize)] +#[derive(Serialize)] struct Page { title: String, permalink: String, @@ -111,10 +111,21 @@ fn main() { } }; + let liquid_parser = liquid::ParserBuilder::with_stdlib() + .build().expect("calathea: failed to build liquid parser"); + + let liquid_template = match liquid_parser.parse(template.as_str()) { + Ok(t) => t, + Err(e) => { + println!("calathea: failed to parse template '{}': {}", template_path.display(), e); + process::exit(1); + } + }; + let mut page_map: HashMap = HashMap::new(); let mut content_map: HashMap = HashMap::new(); - let mut incoming_map: HashMap> = HashMap::new(); + let mut incoming_map: HashMap> = HashMap::new(); // Pull the source files into memory let src_paths = match fs::read_dir(src_dir) { @@ -207,7 +218,7 @@ fn main() { let incoming_pages = incoming_map.get_mut(&name).unwrap(); - incoming_pages.push(page.clone()); + incoming_pages.push(page); } content_map.insert(page.title.clone(), link_re.replace_all(original_content.as_str(), |caps: &Captures| { @@ -231,19 +242,8 @@ fn main() { md_options.extension.footnotes = true; md_options.extension.front_matter_delimiter = Some("---".to_owned()); - let liquid_parser = liquid::ParserBuilder::with_stdlib() - .build().expect("calathea: failed to build liquid parser"); - - let liquid_template = match liquid_parser.parse(template.as_str()) { - Ok(t) => t, - Err(e) => { - println!("calathea: failed to parse template '{}': {}", template_path.display(), e); - process::exit(1); - } - }; - for page in page_map.values() { - let incoming_pages: &Vec = incoming_map.get(&page.title).unwrap(); + let incoming_pages = incoming_map.get(&page.title).unwrap(); let content = content_map.get(&page.title).unwrap(); let globals = liquid::object!({