diff --git a/Cargo.lock b/Cargo.lock index 4c54a63..a63ab92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -146,7 +146,7 @@ dependencies = [ "serde", "serde_yaml", "syntect", - "unicode-width", + "unicode-width", ] [[package]] @@ -2431,9 +2431,9 @@ dependencies = [ "cfg-if 1.0.0", "libc", "rand", - "redox_syscall 0.2.4", - "remove_dir_all", - "winapi", + "redox_syscall 0.2.4", + "remove_dir_all", + "winapi", ] [[package]] diff --git a/README.md b/README.md index 69fdc63..4924217 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,8 @@ The following keys can be used inside the template: * `{{ relative_path }}` - path relative to KB directory * `{{ absolute_path }}` - full path on filesystem * `annotations` - a list of *rendered* annotations (according to the annotation template) +* `raw_annotations` - a list of annotations (in case you need info for the page about the annotations - + e.g. `{{raw_annotations.0.title}}`) The default template is: diff --git a/src/configuration.rs b/src/configuration.rs index b2a5aa0..0d0986f 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -633,10 +633,14 @@ file_extension = '{}' relative_path: "relative/path/to/page.md".to_string(), absolute_path: "absolute/path/to/page.md".to_string(), }, - annotations: vec![test_annotation_1, test_annotation_2] + annotations: vec![test_annotation_1.clone(), test_annotation_2.clone()] .into_iter() .map(|a| hbs.render("annotation", &AnnotationTemplate::from_annotation(a))) .collect::, _>>()?, + raw_annotations: vec![ + AnnotationTemplate::from_annotation(test_annotation_1), + AnnotationTemplate::from_annotation(test_annotation_2), + ], }; self.page_template = loop { diff --git a/src/gooseberry/knowledge_base.rs b/src/gooseberry/knowledge_base.rs index 8fc36e1..3a3d79f 100644 --- a/src/gooseberry/knowledge_base.rs +++ b/src/gooseberry/knowledge_base.rs @@ -154,6 +154,7 @@ pub struct PageTemplate { #[serde(flatten)] pub link_data: LinkTemplate, pub annotations: Vec, + pub raw_annotations: Vec, } /// ## Markdown generation @@ -360,9 +361,10 @@ impl Gooseberry { let page_data = PageTemplate { link_data, annotations: inner_annotations - .into_iter() + .iter() .map(|a| hbs.render("annotation", &a)) .collect::, _>>()?, + raw_annotations: inner_annotations, }; fs::File::create(&path)? .write_all(hbs.render("page", &page_data)?.as_bytes())?;