diff --git a/book-example/src/format/theme/README.md b/book-example/src/format/theme/README.md index f1fd303a8a..ac159ba987 100644 --- a/book-example/src/format/theme/README.md +++ b/book-example/src/format/theme/README.md @@ -11,16 +11,18 @@ and now that file will be used instead of the default file. Here are the files you can override: -- ***index.hbs*** is the handlebars template. -- ***book.css*** is the style used in the output. If you want to change the +- **_index.hbs_** is the handlebars template. +- **_head.hbs_** is appended to the HTML `
` section. +- **_header.hbs_** content is appended on top of every book page. +- **_book.css_** is the style used in the output. If you want to change the design of your book, this is probably the file you want to modify. Sometimes in conjunction with `index.hbs` when you want to radically change the layout. -- ***book.js*** is mostly used to add client side functionality, like hiding / +- **_book.js_** is mostly used to add client side functionality, like hiding / un-hiding the sidebar, changing the theme, ... -- ***highlight.js*** is the JavaScript that is used to highlight code snippets, - you should not need to modify this. -- ***highlight.css*** is the theme used for the code highlighting -- ***favicon.png*** the favicon that will be used +- **_highlight.js_** is the JavaScript that is used to highlight code snippets, + you should not need to modify this. +- **_highlight.css_** is the theme used for the code highlighting. +- **_favicon.png_** the favicon that will be used. Generally, when you want to tweak the theme, you don't need to override all the files. If you only need changes in the stylesheet, there is no point in diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 14012c12d4..cea3a9fdca 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -327,6 +327,9 @@ impl Renderer for HtmlHandlebars { debug!("Register the index handlebars template"); handlebars.register_template_string("index", String::from_utf8(theme.index.clone())?)?; + debug!("Register the head handlebars template"); + handlebars.register_partial("head", String::from_utf8(theme.head.clone())?)?; + debug!("Register the header handlebars template"); handlebars.register_partial("header", String::from_utf8(theme.header.clone())?)?; diff --git a/src/theme/head.hbs b/src/theme/head.hbs new file mode 100644 index 0000000000..cb1be1876c --- /dev/null +++ b/src/theme/head.hbs @@ -0,0 +1 @@ +{{!-- Put your head HTML text here --}} diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 291e279659..e27f6aa354 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -8,6 +8,9 @@ {{/if}} + + {{> head}} + diff --git a/src/theme/mod.rs b/src/theme/mod.rs index aab96db732..1172922ff8 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -12,6 +12,7 @@ use std::path::Path; use crate::errors::*; pub static INDEX: &[u8] = include_bytes!("index.hbs"); +pub static HEAD: &[u8] = include_bytes!("head.hbs"); pub static HEADER: &[u8] = include_bytes!("header.hbs"); pub static CHROME_CSS: &[u8] = include_bytes!("css/chrome.css"); pub static GENERAL_CSS: &[u8] = include_bytes!("css/general.css"); @@ -42,6 +43,7 @@ pub static FONT_AWESOME_OTF: &[u8] = include_bytes!("FontAwesome/fonts/FontAweso #[derive(Debug, PartialEq)] pub struct Theme { pub index: Vec