
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
mkdocs-toggle-sidebar-plugin
Advanced tools
Add keybindings to toggle the navigation and table of contents sidebars
This package allows you to toggle the left (navigation) and right (table of contents) sidebars on a couple of MkDocs themes such as:
material
mkdocs
, readthedocs
You can play around with it and these themes on the test page.
The settings are stored using the localStorage
object, so that it will persist between pages.
I wrote it after getting frustrated by the browser's Find in page
function matching way to many links in the navigation sidebar instead of searching in the actual page's content.
First install the PyPI package:
pip install mkdocs-toggle-sidebar-plugin
Add something like the following to your mkdocs.yml
:
plugins:
- search
- toggle-sidebar
The plugin adds the following key bindings:
Key | Action |
---|---|
b | toggle both (TOC and navigation) |
m | toggle navigation menu |
t | toggle TOC |
For some themes like readthedocs
navigation and TOC are combined.
In this case the state of TOC is ignored, and only calls for navigation (or all) are interpreted.
When you set the toggle_button
option to navigation
, toc
or all
, it will add a button that looks like a hamburger menu (three horizontal bars) on a theme-dependent location.
It is usually in the nav or the top bar.
Clicking the button will toggle the navigation, table of contents, or both (depending on the supplied value).
By leaving the field empty or setting it to none
, no button is added.
This plugin exposes some JavaScript functions, that can show, hide or toggle the visibility of the sidebars.
You can see how they are called in docs/javascript-functions.md
and how they are defined in src/mkdocs_toggle_sidebar_plugin/toggle-sidebar.js
.
In short there are:
MkdocsToggleSidebarPlugin.setNavigationVisibility(show: bool)
MkdocsToggleSidebarPlugin.setTocVisibility(show: bool)
MkdocsToggleSidebarPlugin.setAllVisibility: (showNavigation: bool, showTOC: bool)
MkdocsToggleSidebarPlugin.toggleNavigationVisibility()
MkdocsToggleSidebarPlugin.toggleTocVisibility()
MkdocsToggleSidebarPlugin.toggleAllVisibility()
The names and parameters should be self-explanatory.
Below shows the latest themes that I have tested. They are not updated that often, and the plugin should generally work for other of theme versions too.
Theme | Theme version | Plugin version | Status |
---|---|---|---|
mkdocs-material | 9.5.34 | 0.0.4 | works |
mkdocs (default) | 1.6.1 | 0.0.4 | works |
readthedocs | 1.6.1 | 0.0.4 | works |
Just open a issue / PR if you use a strange theme or the info above is not up to date anymore.
Test mkdocs-material theme:
./serve.sh
Test mkdocs theme:
./serve.sh --theme mkdocs
MkdocsToggleSidebarPlugin
object.
This lets you create custom buttons or key bindings to hide, show or toggle the side bars.toggle_button
option and implemented it for Material theme.mkdocs
and readthedocs
theme.mkdocs-material
implementation.FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.