diff --git a/src/book/mod.rs b/src/book/mod.rs index fc757a90..a22473e5 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -263,6 +263,10 @@ impl MDBook { let mut index = File::create(themedir.join("index.hbs"))?; index.write_all(theme::INDEX)?; + // header.hbs + let mut header = File::create(themedir.join("header.hbs"))?; + header.write_all(theme::HEADER)?; + // book.css let mut css = File::create(themedir.join("book.css"))?; css.write_all(theme::CSS)?; diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index f8186948..14e45c23 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -253,8 +253,17 @@ impl Renderer for HtmlHandlebars { let theme = theme::Theme::new(theme_dir); - debug!("[*]: Register handlebars template"); - handlebars.register_template_string("index", String::from_utf8(theme.index.clone())?)?; + debug!("[*]: Register the index handlebars template"); + handlebars.register_template_string( + "index", + String::from_utf8(theme.index.clone())?, + )?; + + debug!("[*]: Register the header handlebars template"); + handlebars.register_partial( + "header", + String::from_utf8(theme.header.clone())?, + )?; debug!("[*]: Register handlebars helpers"); self.register_hbs_helpers(&mut handlebars); diff --git a/src/theme/header.hbs b/src/theme/header.hbs new file mode 100644 index 00000000..26fa2d2e --- /dev/null +++ b/src/theme/header.hbs @@ -0,0 +1 @@ +{{!-- Put your header HTML text here --}} \ No newline at end of file diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 83c3d5d5..2a6c34ee 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -74,6 +74,7 @@
+ {{> header}}