Skip to content

Commit

Permalink
Prevent theme mamangement to raise error when the mode is fixed (#692)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
  • Loading branch information
12rambau and choldgraf committed Jun 4, 2022
1 parent 46de2f6 commit 7f12569
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 14 additions & 2 deletions docs/user_guide/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,24 @@ The theme mode can be changed by the user. By default landing on the documentati
.. code-block:: python
html_context = {
...
"default_mode": "auto"
# ...
"default_mode": "light"
}
For more information, see :ref:`manage-themes`.

.. tip::

To completely remove the theme management, configure ``default_mode`` to the value you want in your documentation (``light`` or ``dark``) and then remove the theme-switcher from the ``navbar_end`` section of the header navbar configuration:

.. code-block:: python
html_theme_options {
# ...
# Note we have omitted `theme-switcher` below
"navbar_end": ["navbar-icon-links"]
}
Configure pygment theme
=======================

Expand Down
4 changes: 3 additions & 1 deletion src/pydata_sphinx_theme/assets/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ function addModeListener() {

// Attach event handlers for toggling themes colors
const btn = document.getElementById("theme-switch");
btn.addEventListener("click", cycleMode);
if (btn != null) {
btn.addEventListener("click", cycleMode);
}
}

/*******************************************************************************
Expand Down

0 comments on commit 7f12569

Please sign in to comment.