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 {
|
pub struct Chapter {
|
||||||
/// The chapter's name.
|
/// The chapter's name.
|
||||||
pub name: String,
|
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.
|
/// The chapter's contents.
|
||||||
pub content: String,
|
pub content: String,
|
||||||
/// The chapter's section number, if it has one.
|
/// The chapter's section number, if it has one.
|
||||||
|
@ -174,6 +176,7 @@ impl Chapter {
|
||||||
) -> Chapter {
|
) -> Chapter {
|
||||||
Chapter {
|
Chapter {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
|
chapter_config: serde_json::Map::with_capacity(0),
|
||||||
content,
|
content,
|
||||||
path: Some(path.into()),
|
path: Some(path.into()),
|
||||||
parent_names,
|
parent_names,
|
||||||
|
@ -186,6 +189,7 @@ impl Chapter {
|
||||||
pub fn new_draft(name: &str, parent_names: Vec<String>) -> Self {
|
pub fn new_draft(name: &str, parent_names: Vec<String>) -> Self {
|
||||||
Chapter {
|
Chapter {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
|
chapter_config: serde_json::Map::with_capacity(0),
|
||||||
content: String::new(),
|
content: String::new(),
|
||||||
path: None,
|
path: None,
|
||||||
parent_names,
|
parent_names,
|
||||||
|
@ -435,6 +439,7 @@ And here is some \
|
||||||
|
|
||||||
let nested = Chapter {
|
let nested = Chapter {
|
||||||
name: String::from("Nested Chapter 1"),
|
name: String::from("Nested Chapter 1"),
|
||||||
|
chapter_config: serde_json::Map::with_capacity(0),
|
||||||
content: String::from("Hello World!"),
|
content: String::from("Hello World!"),
|
||||||
number: Some(SectionNumber(vec![1, 2])),
|
number: Some(SectionNumber(vec![1, 2])),
|
||||||
path: Some(PathBuf::from("second.md")),
|
path: Some(PathBuf::from("second.md")),
|
||||||
|
@ -443,6 +448,7 @@ And here is some \
|
||||||
};
|
};
|
||||||
let should_be = BookItem::Chapter(Chapter {
|
let should_be = BookItem::Chapter(Chapter {
|
||||||
name: String::from("Chapter 1"),
|
name: String::from("Chapter 1"),
|
||||||
|
chapter_config: serde_json::Map::with_capacity(0),
|
||||||
content: String::from(DUMMY_SRC),
|
content: String::from(DUMMY_SRC),
|
||||||
number: None,
|
number: None,
|
||||||
path: Some(PathBuf::from("chapter_1.md")),
|
path: Some(PathBuf::from("chapter_1.md")),
|
||||||
|
@ -507,6 +513,7 @@ And here is some \
|
||||||
sections: vec![
|
sections: vec![
|
||||||
BookItem::Chapter(Chapter {
|
BookItem::Chapter(Chapter {
|
||||||
name: String::from("Chapter 1"),
|
name: String::from("Chapter 1"),
|
||||||
|
chapter_config: serde_json::Map::with_capacity(0),
|
||||||
content: String::from(DUMMY_SRC),
|
content: String::from(DUMMY_SRC),
|
||||||
number: None,
|
number: None,
|
||||||
path: Some(PathBuf::from("Chapter_1/index.md")),
|
path: Some(PathBuf::from("Chapter_1/index.md")),
|
||||||
|
@ -559,6 +566,7 @@ And here is some \
|
||||||
sections: vec![
|
sections: vec![
|
||||||
BookItem::Chapter(Chapter {
|
BookItem::Chapter(Chapter {
|
||||||
name: String::from("Chapter 1"),
|
name: String::from("Chapter 1"),
|
||||||
|
chapter_config: serde_json::Map::with_capacity(0),
|
||||||
content: String::from(DUMMY_SRC),
|
content: String::from(DUMMY_SRC),
|
||||||
number: None,
|
number: None,
|
||||||
path: Some(PathBuf::from("Chapter_1/index.md")),
|
path: Some(PathBuf::from("Chapter_1/index.md")),
|
||||||
|
|
Loading…
Reference in New Issue