Merge pull request #193 from mbrubeck/chapter-title

Add current chapter title to handlebars context
This commit is contained in:
Mathieu David 2016-12-31 23:43:39 +01:00 committed by GitHub
commit a6e1844aad
3 changed files with 6 additions and 2 deletions

View File

@ -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.
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.

View File

@ -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());

View File

@ -2,7 +2,7 @@
<html lang="{{ language }}">
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
<title>{{ chapter_title }} - {{ title }}</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="{{ description }}">
<meta name="viewport" content="width=device-width, initial-scale=1">