Skip to content

Commit

Permalink
Don't try to populate version switcher on static sites
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Jan 19, 2024
1 parent a135c20 commit 7e88600
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ async function fetchVersionSwitcherJSON(url) {
var result = new URL(url);
} catch (err) {
if (err instanceof TypeError) {
if (window.location.protocol == "file:") {
// TODO: Fix this to return the version switcher on static builds
return null;
}
// assume we got a relative path, and fix accordingly. But first, we need to
// use `fetch()` to follow redirects so we get the correct final base URL
const origin = await fetch(window.location.origin, { method: "HEAD" });
Expand Down Expand Up @@ -556,9 +560,11 @@ if (hasVersionsJSON && (hasSwitcherMenu || wantsWarningBanner)) {
const data = await fetchVersionSwitcherJSON(
DOCUMENTATION_OPTIONS.theme_switcher_json_url
);
populateVersionSwitcher(data, versionSwitcherBtns);
if (wantsWarningBanner) {
showVersionWarningBanner(data);
if (data) {
populateVersionSwitcher(data, versionSwitcherBtns);
if (wantsWarningBanner) {
showVersionWarningBanner(data);
}
}
}

Expand Down

0 comments on commit 7e88600

Please sign in to comment.