From 3e78528cc8025d93dc2ccd25cafb07ed85a331dd Mon Sep 17 00:00:00 2001 From: Gabriel Fouasnon Date: Wed, 6 Sep 2023 10:57:25 +0300 Subject: [PATCH 01/23] Fix duplicate HTML IDs --- .../components/navbar-nav.html | 10 ++++++- .../components/version-switcher.html | 26 +++++++++++++---- .../pydata_sphinx_theme/sections/header.html | 4 +++ .../sections/sidebar-primary.html | 4 +++ src/pydata_sphinx_theme/toctree.py | 28 ++++++++++++++++--- 5 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-nav.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-nav.html index 7678a152d..0eeaf4934 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-nav.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-nav.html @@ -1,3 +1,9 @@ +{% set base_id = "pst-more-nav-links" %} +{% if parent_template_name %} + {% set dropdown_id = create_next_id(base_id + "-in-" + parent_template_name) %} +{% else %} + {% set dropdown_id = create_next_id(base_id) %} +{% endif %} diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/version-switcher.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/version-switcher.html index 974aa8c87..bde1a4437 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/version-switcher.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/version-switcher.html @@ -1,14 +1,28 @@ -{# As the version switcher will only work when JavaScript is enabled, we add it through JavaScript. - #} +{# As the version switcher will only work when JavaScript is enabled, we add it through JavaScript. #} +{% set base_button_id = "pst-version-switcher-button" %} +{% set base_dropdown_id = "pst-version-switcher-list" %} +{% if parent_template_name %} + {% set button_id = create_next_id(base_button_id + "-in-" + parent_template_name) %} + {% set dropdown_id = create_next_id(base_dropdown_id + "-in-" + parent_template_name) %} +{% else %} + {% set button_id = create_next_id(base_button_id) %} + {% set dropdown_id = create_next_id(base_dropdown_id) %} +{% endif %}