From fa3870b06f5f2ebd95fcaeba04d75a81c8b7064d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Guth?= Date: Tue, 22 Jun 2021 15:11:49 +0200 Subject: [PATCH 01/29] Add a config variable for a logo path --- crates/mdbook-core/src/config.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/mdbook-core/src/config.rs b/crates/mdbook-core/src/config.rs index d7aa13bb89..58c2321334 100644 --- a/crates/mdbook-core/src/config.rs +++ b/crates/mdbook-core/src/config.rs @@ -330,6 +330,9 @@ pub struct BookConfig { /// The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL). /// When not specified, the text direction is derived from [`BookConfig::language`]. pub text_direction: Option, + /// A logo to be displayed on top of the navigation bar. The path is relative to the source + /// path + pub logo: Option, } /// Helper for serde serialization. @@ -346,6 +349,7 @@ impl Default for BookConfig { src: PathBuf::from("src"), language: Some(String::from("en")), text_direction: None, + logo: None, } } } @@ -779,6 +783,8 @@ mod tests { src: PathBuf::from("source"), language: Some(String::from("ja")), text_direction: None, + // TODO: add a test logo + logo: None, }; let build_should_be = BuildConfig { build_dir: PathBuf::from("outputs"), From fb415da8caa23d39b200207bdd231d4a3de9bbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Guth?= Date: Thu, 24 Jun 2021 14:43:07 +0200 Subject: [PATCH 02/29] Add a logo to the HTML template The logo is placed at the top of the navication sidebar. --- crates/mdbook-html/front-end/css/chrome.css | 7 +++++++ crates/mdbook-html/front-end/templates/index.hbs | 5 +++++ crates/mdbook-html/src/html_handlebars/hbs_renderer.rs | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/crates/mdbook-html/front-end/css/chrome.css b/crates/mdbook-html/front-end/css/chrome.css index 19b8e90f9d..18b462943a 100644 --- a/crates/mdbook-html/front-end/css/chrome.css +++ b/crates/mdbook-html/front-end/css/chrome.css @@ -498,6 +498,13 @@ html:not(.sidebar-resizing) .sidebar { right: 0; padding: 10px 10px; } +.sidebar .sidebar-scrollbox .sidebar-book-logo img { + display: block; + margin-left: auto; + margin-right: auto; + max-width: max-content; + width: 100%; +} .sidebar .sidebar-resize-handle { position: absolute; cursor: col-resize; diff --git a/crates/mdbook-html/front-end/templates/index.hbs b/crates/mdbook-html/front-end/templates/index.hbs index b1834189f9..4f982bfd0e 100644 --- a/crates/mdbook-html/front-end/templates/index.hbs +++ b/crates/mdbook-html/front-end/templates/index.hbs @@ -126,6 +126,11 @@