Skip to content

Commit 2e88b0f

Browse files
Show the right sidebar on wider screens if the left is hidden (#570)
1 parent 1812667 commit 2e88b0f

File tree

1 file changed

+13
-7
lines changed
  • src/pydata_sphinx_theme/theme/pydata_sphinx_theme

1 file changed

+13
-7
lines changed

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,18 @@
6969
{% endblock %}
7070

7171
{% block docs_toc %}
72-
<div class="d-none d-xl-block col-xl-2 bd-toc">
72+
{# Define content / TOC behavior depending on whether we have sidebars #}
73+
{%- if sidebars -%}
74+
{#- Sidebar == less horizontal space, so only show TOC on xl screens and use narrower width for content. -#}
75+
{% set content_xl_width = "col-xl-7" %}
76+
{% set toc_show_width = "xl" %}
77+
{% else %}
78+
{#- No sidebar, so show the TOC on md screens and use more width for content. -#}
79+
{% set content_xl_width = "col-xl-8" %}
80+
{% set toc_show_width = "md" %}
81+
{%- endif -%}
82+
83+
<div class="d-none d-{{ toc_show_width }}-block col-{{ toc_show_width }}-2 bd-toc">
7384
{% if meta is defined and not (meta is not none and 'notoc' in meta) %}
7485
{% for toc_item in theme_page_sidebar_items %}
7586
<div class="toc-item">
@@ -81,12 +92,7 @@
8192
{% endblock %}
8293

8394
{% block docs_main %}
84-
{% if sidebars %}
85-
{% set content_col_class = "col-md-9 col-xl-7" %}
86-
{% else %}
87-
{% set content_col_class = "col-md-11 col-xl-8" %}
88-
{% endif %}
89-
<main class="col-12 {{ content_col_class }} py-md-5 pl-md-5 pr-md-4 bd-content" role="main">
95+
<main class="col-12 col-md-9 {{ content_xl_width }} py-md-5 pl-md-5 pr-md-4 bd-content" role="main">
9096
{% block docs_body %}
9197
<div>
9298
{% block body %} {% endblock %}

0 commit comments

Comments
 (0)