Add current chapter title to handlebars context
This commit is contained in:
parent
f1df53a4bb
commit
3a0cfc87df
|
@ -20,6 +20,7 @@ Here is a list of the properties that are exposed:
|
||||||
- ***language*** Language of the book in the form `en`. To use in <code class="language-html">\<html lang="{{ language }}"></code> for example.
|
- ***language*** Language of the book in the form `en`. To use in <code class="language-html">\<html lang="{{ language }}"></code> for example.
|
||||||
At the moment it is hardcoded.
|
At the moment it is hardcoded.
|
||||||
- ***title*** Title of the book, as specified in `book.toml`
|
- ***title*** Title of the book, as specified in `book.toml`
|
||||||
|
- ***chapter_title*** Title of the current chapter, as listed in `SUMMARY.md`
|
||||||
|
|
||||||
- ***path*** Relative path to the original markdown file from the source directory
|
- ***path*** Relative path to the original markdown file from the source directory
|
||||||
- ***content*** This is the rendered markdown.
|
- ***content*** This is the rendered markdown.
|
||||||
|
|
|
@ -93,11 +93,14 @@ impl Renderer for HtmlHandlebars {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Remove content from previous file and render content for this one
|
// Remove content from previous file and render content for this one
|
||||||
data.remove("content");
|
data.remove("content");
|
||||||
data.insert("content".to_owned(), content.to_json());
|
data.insert("content".to_owned(), content.to_json());
|
||||||
|
|
||||||
|
// Remove chapter title from previous file and add title for this one
|
||||||
|
data.remove("chapter_title");
|
||||||
|
data.insert("chapter_title".to_owned(), ch.name.to_json());
|
||||||
|
|
||||||
// Remove path to root from previous file and render content for this one
|
// Remove path to root from previous file and render content for this one
|
||||||
data.remove("path_to_root");
|
data.remove("path_to_root");
|
||||||
data.insert("path_to_root".to_owned(), utils::fs::path_to_root(&ch.path).to_json());
|
data.insert("path_to_root".to_owned(), utils::fs::path_to_root(&ch.path).to_json());
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<html lang="{{ language }}">
|
<html lang="{{ language }}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{{ title }}</title>
|
<title>{{ chapter_title }} - {{ title }}</title>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||||
<meta name="description" content="{{ description }}">
|
<meta name="description" content="{{ description }}">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
Loading…
Reference in New Issue