Skip to content

Commit 20a0b99

Browse files
committed
Fix favicon when only one is overridden.
A mistake in #1266, I neglected to also update the <link> generation to elide the link if one of the favicon images is not included.
1 parent ec495a7 commit 20a0b99

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/renderer/html_handlebars/hbs_renderer.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl Renderer for HtmlHandlebars {
478478
debug!("Register handlebars helpers");
479479
self.register_hbs_helpers(&mut handlebars, &html_config);
480480

481-
let mut data = make_data(&ctx.root, &book, &ctx.config, &html_config)?;
481+
let mut data = make_data(&ctx.root, &book, &ctx.config, &html_config, &theme)?;
482482

483483
// Print version
484484
let mut print_content = String::new();
@@ -551,6 +551,7 @@ fn make_data(
551551
book: &Book,
552552
config: &Config,
553553
html_config: &HtmlConfig,
554+
theme: &Theme,
554555
) -> Result<serde_json::Map<String, serde_json::Value>> {
555556
trace!("make_data");
556557

@@ -567,6 +568,12 @@ fn make_data(
567568
"description".to_owned(),
568569
json!(config.book.description.clone().unwrap_or_default()),
569570
);
571+
if theme.favicon_png.is_some() {
572+
data.insert("favicon_png".to_owned(), json!("favicon.png"));
573+
}
574+
if theme.favicon_svg.is_some() {
575+
data.insert("favicon_svg".to_owned(), json!("favicon.svg"));
576+
}
570577
if let Some(ref livereload) = html_config.livereload_url {
571578
data.insert("livereload".to_owned(), json!(livereload));
572579
}

src/theme/index.hbs

+4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
<meta name="viewport" content="width=device-width, initial-scale=1">
2121
<meta name="theme-color" content="#ffffff" />
2222

23+
{{#if favicon_svg}}
2324
<link rel="icon" href="{{ path_to_root }}favicon.svg">
25+
{{/if}}
26+
{{#if favicon_png}}
2427
<link rel="shortcut icon" href="{{ path_to_root }}favicon.png">
28+
{{/if}}
2529
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
2630
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
2731
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">

0 commit comments

Comments
 (0)