added a chapter_config field to the Chapter structure
This commit is contained in:
parent
ba4a5d0665
commit
c5aa243e0f
|
@ -152,6 +152,8 @@ impl From<Chapter> 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<String, serde_json::Value>,
|
||||
/// 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<String>) -> 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")),
|
||||
|
|
Loading…
Reference in New Issue