Skip to content

Commit 3ebd74f

Browse files
authored
Allow relative json url to work locally (and hopefully on PRs) (#599)
1 parent 8785747 commit 3ebd74f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

docs/conf.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
html_theme = "pydata_sphinx_theme"
7979
# html_logo = "_static/pandas.svg" # For testing
8080

81+
# Define the json_url for our version switcher.
82+
json_url = "https://pydata-sphinx-theme.readthedocs.io/en/latest/_static/switcher.json"
83+
8184
# Define the version we use for matching in the version switcher.
8285
version_match = os.environ.get("READTHEDOCS_VERSION")
8386
# If READTHEDOCS_VERSION doesn't exist, we're not on RTD
@@ -87,6 +90,9 @@
8790
release = pydata_sphinx_theme.__version__
8891
if "dev" in release:
8992
version_match = "latest"
93+
# We want to keep the relative reference if we are in dev mode
94+
# but we want the whole url if we are effectively in a released version
95+
json_url = "/_static/switcher.json"
9096
else:
9197
version_match = "v" + release
9298

@@ -124,8 +130,7 @@
124130
# "left_sidebar_end": ["custom-template.html", "sidebar-ethical-ads.html"],
125131
# "footer_items": ["copyright", "sphinx-version", ""]
126132
"switcher": {
127-
# "json_url": "/_static/switcher.json",
128-
"json_url": "https://pydata-sphinx-theme.readthedocs.io/en/latest/_static/switcher.json",
133+
"json_url": json_url,
129134
"url_template": "https://pydata-sphinx-theme.readthedocs.io/en/{version}/",
130135
"version_match": version_match,
131136
},

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/_templates/version-switcher.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
$("#version_switcher_button").text(entry.name);
7777
// Add extra class to the button for the selected entry
7878
if ("extra_classes" in entry) {
79-
$("#version_switcher_menu").classList.add(...entry.extra_classes);
79+
$("#version_switcher_menu")[0].classList.add(...entry.extra_classes);
8080
}
8181
}
8282
});

0 commit comments

Comments
 (0)