Skip to content

Commit

Permalink
Do not generate dropdown in sidebar.
Browse files Browse the repository at this point in the history
This should fix pydata#1735, it is complementary to pydata#1564 but with a different
approach.

Instead of generating the same navbar as the fullpage width one, it
generate one with no dropdowns, with this, any css that tries to make
downtown looks like normal links in html becomes unnecessary.

Co-authored-by: gabalafou <[email protected]>
  • Loading branch information
Carreau and gabalafou committed May 2, 2024
1 parent f30dec3 commit 13e38b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
{% if theme_navbar_center %}
<div class="sidebar-header-items__center">
{% for navbar_item in theme_navbar_center %}
<div class="navbar-item">{% include navbar_item %}</div>
{#
In the mobile sidebar we do not want a dropdown, so set a large cutoff (999).
#}
{% with theme_header_links_before_dropdown=999 %}
<div class="navbar-item">{% include navbar_item %}</div>
{% endwith %}
{% endfor %}
</div>
{% endif %}
Expand Down
16 changes: 13 additions & 3 deletions src/pydata_sphinx_theme/toctree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from functools import cache
from itertools import count
from typing import Iterator, List, Union
from typing import Iterator, List, Tuple, Union
from urllib.parse import urlparse

import sphinx
Expand Down Expand Up @@ -101,8 +101,18 @@ def unique_html_id(base_id: str):
return next(get_or_create_id_generator(base_id))

@cache
def generate_header_nav_before_dropdown(n_links_before_dropdown):
"""The cacheable part."""
def generate_header_nav_before_dropdown(
n_links_before_dropdown,
) -> Tuple[str, List[str]]:
"""Return html for navbar and dropdown.
Given the number of links before the dropdown, return the html for the navbar,
as well as the list of links to put in a dropdown.
Returns:
- HTML str for the navbar
- list of HTML str for the dropdown
"""
try:
n_links_before_dropdown = int(n_links_before_dropdown)
except Exception:
Expand Down

0 comments on commit 13e38b8

Please sign in to comment.