have the data for the handlebars template be merged with the
chapter_config preserving the chapter title
This commit is contained in:
parent
44153e5ebf
commit
b9782b0ec2
|
@ -72,7 +72,9 @@ impl HtmlHandlebars {
|
|||
ctx.data.insert("path".to_owned(), json!(path));
|
||||
ctx.data.insert("content".to_owned(), json!(content));
|
||||
ctx.data.insert("chapter_title".to_owned(), json!(ch.name));
|
||||
ctx.data.insert("title".to_owned(), json!(title));
|
||||
if let Some(title) = ctx.data.insert("title".to_owned(), json!(title)) {
|
||||
ctx.data.insert("title".to_string(), title);
|
||||
}
|
||||
ctx.data.insert(
|
||||
"path_to_root".to_owned(),
|
||||
json!(utils::fs::path_to_root(&path)),
|
||||
|
@ -494,10 +496,19 @@ impl Renderer for HtmlHandlebars {
|
|||
|
||||
let mut is_index = true;
|
||||
for item in book.iter() {
|
||||
let item_data = if let BookItem::Chapter(ref ch) = item {
|
||||
let mut chapter_data = data.clone();
|
||||
for (key, value) in ch.chapter_config.iter() {
|
||||
let _ = chapter_data.insert(key.to_string(), json!(value));
|
||||
}
|
||||
chapter_data
|
||||
} else {
|
||||
data.clone()
|
||||
};
|
||||
let ctx = RenderItemContext {
|
||||
handlebars: &handlebars,
|
||||
destination: destination.to_path_buf(),
|
||||
data: data.clone(),
|
||||
data: item_data,
|
||||
is_index,
|
||||
html_config: html_config.clone(),
|
||||
edition: ctx.config.rust.edition,
|
||||
|
|
Loading…
Reference in New Issue