Skip to content

Commit

Permalink
Merge branch 'p/38285/add-version-selector' into p/38285/add-version-…
Browse files Browse the repository at this point in the history
…selector-TEST
  • Loading branch information
kwankyu committed Jul 1, 2024
2 parents d8262f9 + c3dc3c1 commit 6940f19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/doc/common/static/jupyter-sphinx-furo.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ async function fetchVersions() {
let text = await response.text();
let lines = text.split('\n');

let url = window.location.origin;
let current_version

if (window.location.protocol == 'file:') {
current_version = 'local'
url = window.location.href
current_version = 'local';
url = window.location.href;
} else {
let url = window.location.origin;
let start_index = url.indexOf('doc-') + 4;
let end_index = url.indexOf('--');
let version_string = url.substring(start_index, end_index);
let current_version

// Consult the comment in .github/workflows/doc-publish.yml
if (/^pr-\d+$/.test(version_string)) {
Expand Down Expand Up @@ -140,11 +141,11 @@ fetchVersions()

// Function to change the version based on versions menu selection
function changeVersion() {
let selectedVersion = document.getElementById("versions-menu").value;
if (selectedVersion) {
let selected_version = document.getElementById("versions-menu").value;
if (selected_version) {
// Check if the version exists in the map and redirect
if (selectedVersion in versionMap) {
let targetUrl = versionMap[selectedVersion];
if (selected_version in versionMap) {
let targetUrl = versionMap[selected_version];
window.location.href = targetUrl + window.location.pathname;
} else {
console.error("Version not found in versions.txt.");
Expand Down
2 changes: 0 additions & 2 deletions src/doc/en/website/versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#
# Do not edit manually
dev doc-release--sagemath.netlify.app
10.5 doc-10-5--sagemath.netlify.app
10.5 doc-10-5--sagemath.netlify.app
10.4 doc-10-4--sagemath.netlify.app
10.3 doc-10-3--sagemath.netlify.app
10.2 doc-10-2--sagemath.netlify.app
Expand Down

0 comments on commit 6940f19

Please sign in to comment.