From 23f5ffd6d6835a55d8a3111a793d533f72a8a10e Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 21 Apr 2020 10:18:44 -0700 Subject: [PATCH] Change default preferred-dark-theme to `navy`. --- book-example/src/format/config.md | 2 +- book-example/src/format/theme/README.md | 6 ++++++ src/config.rs | 2 +- src/renderer/html_handlebars/hbs_renderer.rs | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/book-example/src/format/config.md b/book-example/src/format/config.md index 1660cb51..4178660b 100644 --- a/book-example/src/format/config.md +++ b/book-example/src/format/config.md @@ -172,7 +172,7 @@ The following configuration options are available: - **preferred-dark-theme:** The default dark theme. This theme will be used if the browser requests the dark version of the site via the ['prefers-color-scheme'](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) - CSS media query. Defaults to the same theme as `default-theme`. + CSS media query. Defaults to `navy`. - **curly-quotes:** Convert straight quotes to curly quotes, except for those that occur in code blocks and code spans. Defaults to `false`. - **mathjax-support:** Adds support for [MathJax](mathjax.md). Defaults to diff --git a/book-example/src/format/theme/README.md b/book-example/src/format/theme/README.md index ac159ba9..5cf6a32d 100644 --- a/book-example/src/format/theme/README.md +++ b/book-example/src/format/theme/README.md @@ -34,3 +34,9 @@ functionality. Therefore I recommend to use the file from the default theme as template and only add / modify what you need. You can copy the default theme into your source directory automatically by using `mdbook init --theme` just remove the files you don't want to override. + +If you completely replace all built-in themes, be sure to also set +[`output.html.preferred-dark-theme`] in the config, which defaults to the +built-in `navy` theme. + +[`output.html.preferred-dark-theme`]: ../config.md#html-renderer-options diff --git a/src/config.rs b/src/config.rs index dc712bbb..a426199e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -479,7 +479,7 @@ pub struct HtmlConfig { /// The default theme to use, defaults to 'light' pub default_theme: Option, /// The theme to use if the browser requests the dark version of the site. - /// Defaults to the same as 'default_theme' + /// Defaults to 'navy'. pub preferred_dark_theme: Option, /// Use "smart quotes" instead of the usual `"` character. pub curly_quotes: bool, diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index ecb8359e..4d3e95f2 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -511,7 +511,7 @@ fn make_data( let preferred_dark_theme = match html_config.preferred_dark_theme { Some(ref theme) => theme.to_lowercase(), - None => default_theme, + None => "navy".to_string(), }; data.insert( "preferred_dark_theme".to_owned(),