Skip to content

Commit fe1ba71

Browse files
authored
Merge pull request #1199 from ehuss/preferred-dark-theme
Change default preferred-dark-theme to `navy`.
2 parents 484e5c0 + 23f5ffd commit fe1ba71

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

book-example/src/format/config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ The following configuration options are available:
172172
- **preferred-dark-theme:** The default dark theme. This theme will be used if
173173
the browser requests the dark version of the site via the
174174
['prefers-color-scheme'](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
175-
CSS media query. Defaults to the same theme as `default-theme`.
175+
CSS media query. Defaults to `navy`.
176176
- **curly-quotes:** Convert straight quotes to curly quotes, except for those
177177
that occur in code blocks and code spans. Defaults to `false`.
178178
- **mathjax-support:** Adds support for [MathJax](mathjax.md). Defaults to

book-example/src/format/theme/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ functionality. Therefore I recommend to use the file from the default theme as
3434
template and only add / modify what you need. You can copy the default theme
3535
into your source directory automatically by using `mdbook init --theme` just
3636
remove the files you don't want to override.
37+
38+
If you completely replace all built-in themes, be sure to also set
39+
[`output.html.preferred-dark-theme`] in the config, which defaults to the
40+
built-in `navy` theme.
41+
42+
[`output.html.preferred-dark-theme`]: ../config.md#html-renderer-options

src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ pub struct HtmlConfig {
479479
/// The default theme to use, defaults to 'light'
480480
pub default_theme: Option<String>,
481481
/// The theme to use if the browser requests the dark version of the site.
482-
/// Defaults to the same as 'default_theme'
482+
/// Defaults to 'navy'.
483483
pub preferred_dark_theme: Option<String>,
484484
/// Use "smart quotes" instead of the usual `"` character.
485485
pub curly_quotes: bool,

src/renderer/html_handlebars/hbs_renderer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ fn make_data(
511511

512512
let preferred_dark_theme = match html_config.preferred_dark_theme {
513513
Some(ref theme) => theme.to_lowercase(),
514-
None => default_theme,
514+
None => "navy".to_string(),
515515
};
516516
data.insert(
517517
"preferred_dark_theme".to_owned(),

0 commit comments

Comments
 (0)