diff --git a/book-example/src/format/theme/index-hbs.md b/book-example/src/format/theme/index-hbs.md index e509565a..d2d75fa1 100644 --- a/book-example/src/format/theme/index-hbs.md +++ b/book-example/src/format/theme/index-hbs.md @@ -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 \ for example. At the moment it is hardcoded. - ***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 - ***content*** This is the rendered markdown. diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 27fb214e..0e4ef8df 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -93,11 +93,14 @@ impl Renderer for HtmlHandlebars { }, } - // Remove content from previous file and render content for this one data.remove("content"); 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 data.remove("path_to_root"); data.insert("path_to_root".to_owned(), utils::fs::path_to_root(&ch.path).to_json()); diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 5f9d94d7..48098e05 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -2,7 +2,7 @@ - {{ title }} + {{ chapter_title }} - {{ title }}