Add support for customizing navigation bar styles in the mkdocs theme

This commit is contained in:
Jim Porter
2019-12-16 12:35:26 -08:00
committed by Waylan Limberg
parent 2172c9f999
commit 15e31f7e68
6 changed files with 17 additions and 5 deletions

View File

@@ -68,6 +68,7 @@ your global navigation uses more than one level, things will likely be broken.
* Bugfix: Ensure theme files do not override docs_dir files on Windows (#1876)
* Add canonical tag to `readthedocs` theme (#1669).
* Improved error message for when `git` is not available.
* Add support for `nav_style` theme option for the `mkdocs` theme (#1930).
## Version 1.0.4 (2018-09-07)

View File

@@ -73,6 +73,14 @@ supports the following options:
* __`search`__: Display the search modal. Default: `83` (s)
* __`nav_style`__: This adjusts the visual style for the top navigation bar; by
default, this is set to `primary` (the default), but it can also be set to
`dark` or `light`.
theme:
name: mkdocs
nav_style: dark
[styles]: https://highlightjs.org/static/demo/
### readthedocs

View File

@@ -132,7 +132,8 @@ class ConfigTests(unittest.TestCase):
'highlightjs': True,
'hljs_style': 'github',
'hljs_languages': [],
'shortcuts': {'help': 191, 'next': 78, 'previous': 80, 'search': 83}
'shortcuts': {'help': 191, 'next': 78, 'previous': 80, 'search': 83},
'nav_style': 'primary'
}
}, {
'dirs': [os.path.join(theme_dir, 'readthedocs'), mkdocs_templates_dir],
@@ -194,7 +195,8 @@ class ConfigTests(unittest.TestCase):
'highlightjs': True,
'hljs_style': 'github',
'hljs_languages': [],
'shortcuts': {'help': 191, 'next': 78, 'previous': 80, 'search': 83}
'shortcuts': {'help': 191, 'next': 78, 'previous': 80, 'search': 83},
'nav_style': 'primary'
}
}
)

View File

@@ -34,7 +34,8 @@ class ThemeTests(unittest.TestCase):
'highlightjs': True,
'hljs_style': 'github',
'hljs_languages': [],
'shortcuts': {'help': 191, 'next': 78, 'previous': 80, 'search': 83}
'shortcuts': {'help': 191, 'next': 78, 'previous': 80, 'search': 83},
'nav_style': 'primary'
})
def test_custom_dir(self):

View File

@@ -59,8 +59,7 @@
</head>
<body{% if page and page.is_homepage %} class="homepage"{% endif %}>
<div class="navbar fixed-top navbar-expand-lg navbar-dark bg-primary">
<div class="navbar fixed-top navbar-expand-lg navbar-{% if config.theme.nav_style == "light" %}light{% else %}dark{% endif %} bg-{{ config.theme.nav_style }}">
<div class="container">
<!-- Collapsed navigation -->

View File

@@ -9,6 +9,7 @@ search_index_only: false
highlightjs: true
hljs_languages: []
hljs_style: github
nav_style: primary
shortcuts:
help: 191 # ?