From 20a0b99c3d9ee66714c78b76db4d85f52803e8e4 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 7 Jul 2020 13:37:25 -0700 Subject: [PATCH] Fix favicon when only one is overridden. A mistake in #1266, I neglected to also update the generation to elide the link if one of the favicon images is not included. --- src/renderer/html_handlebars/hbs_renderer.rs | 9 ++++++++- src/theme/index.hbs | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index fa576998..7880817b 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -478,7 +478,7 @@ impl Renderer for HtmlHandlebars { debug!("Register handlebars helpers"); self.register_hbs_helpers(&mut handlebars, &html_config); - let mut data = make_data(&ctx.root, &book, &ctx.config, &html_config)?; + let mut data = make_data(&ctx.root, &book, &ctx.config, &html_config, &theme)?; // Print version let mut print_content = String::new(); @@ -551,6 +551,7 @@ fn make_data( book: &Book, config: &Config, html_config: &HtmlConfig, + theme: &Theme, ) -> Result> { trace!("make_data"); @@ -567,6 +568,12 @@ fn make_data( "description".to_owned(), json!(config.book.description.clone().unwrap_or_default()), ); + if theme.favicon_png.is_some() { + data.insert("favicon_png".to_owned(), json!("favicon.png")); + } + if theme.favicon_svg.is_some() { + data.insert("favicon_svg".to_owned(), json!("favicon.svg")); + } if let Some(ref livereload) = html_config.livereload_url { data.insert("livereload".to_owned(), json!(livereload)); } diff --git a/src/theme/index.hbs b/src/theme/index.hbs index f9d3c5aa..7ad4cbf7 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -20,8 +20,12 @@ + {{#if favicon_svg}} + {{/if}} + {{#if favicon_png}} + {{/if}}