Skip to content

Commit

Permalink
add console message
Browse files Browse the repository at this point in the history
  • Loading branch information
drammock committed Nov 21, 2024
1 parent 79df1cc commit 95b51e2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,17 @@ async function fetchVersionSwitcherJSON(url) {
var result = new URL(url);
} catch (err) {
if (err instanceof TypeError) {
// Assume we got a relative path, and fix accordingly. This also handles local
// static sites (i.e., when window.location.protocol == 'file:'). Normally for
// local static sites CORS policy will always block resource requests, so in
// general the version switcher will always fail to populate if you just open up
// the built HTML files (instead of spinning up a local server). Here instead of
// returning `null` we work out what the file path would be anyway (same code path
// as for served docs), as a convenience to folks who routinely disable CORS when
// they boot up their browser.
// Assume we got a relative path, and fix accordingly.
if (window.location.protocol == "file:") {
// Here instead of returning `null` we work out what the file path would be
// anyway (same code path as for served docs), as a convenience to folks who
// routinely disable CORS when they boot up their browser.
console.info(
"[PST] looks like you're viewing this site from a local filesystem, so " +
"the version switcher won't work unless you've disabled CORS. See " +
"https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/version-dropdown.html",
);
}
const cutoff = window.location.href.indexOf(currentPath);
// cutoff == -1 can happen e.g. on the homepage of locally served docs, where you
// get something like http://127.0.0.1:8000/ (no trailing `index.html`)
Expand Down

0 comments on commit 95b51e2

Please sign in to comment.