diff --git a/src/book/book.rs b/src/book/book.rs index 95382960..014be8f1 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -152,6 +152,8 @@ impl From for BookItem { pub struct Chapter { /// The chapter's name. pub name: String, + /// A collection of key, value pairs for handlebars.js templates. + pub chapter_config: serde_json::Map, /// The chapter's contents. pub content: String, /// The chapter's section number, if it has one. @@ -174,6 +176,7 @@ impl Chapter { ) -> Chapter { Chapter { name: name.to_string(), + chapter_config: serde_json::Map::with_capacity(0), content, path: Some(path.into()), parent_names, @@ -186,6 +189,7 @@ impl Chapter { pub fn new_draft(name: &str, parent_names: Vec) -> Self { Chapter { name: name.to_string(), + chapter_config: serde_json::Map::with_capacity(0), content: String::new(), path: None, parent_names, @@ -435,6 +439,7 @@ And here is some \ let nested = Chapter { name: String::from("Nested Chapter 1"), + chapter_config: serde_json::Map::with_capacity(0), content: String::from("Hello World!"), number: Some(SectionNumber(vec![1, 2])), path: Some(PathBuf::from("second.md")), @@ -443,6 +448,7 @@ And here is some \ }; let should_be = BookItem::Chapter(Chapter { name: String::from("Chapter 1"), + chapter_config: serde_json::Map::with_capacity(0), content: String::from(DUMMY_SRC), number: None, path: Some(PathBuf::from("chapter_1.md")), @@ -507,6 +513,7 @@ And here is some \ sections: vec![ BookItem::Chapter(Chapter { name: String::from("Chapter 1"), + chapter_config: serde_json::Map::with_capacity(0), content: String::from(DUMMY_SRC), number: None, path: Some(PathBuf::from("Chapter_1/index.md")), @@ -559,6 +566,7 @@ And here is some \ sections: vec![ BookItem::Chapter(Chapter { name: String::from("Chapter 1"), + chapter_config: serde_json::Map::with_capacity(0), content: String::from(DUMMY_SRC), number: None, path: Some(PathBuf::from("Chapter_1/index.md")),