diff --git a/docs/_static/js/custom.js b/docs/_static/js/custom.js index 0e67c399435..3c508100bc1 100644 --- a/docs/_static/js/custom.js +++ b/docs/_static/js/custom.js @@ -36,6 +36,7 @@ function addLegalNotice() { $(document).ready(function () { createVersions(); updateTitleTag(); + updateLanguageSelector(); init_col_sections(); init_switchers(); handleSwitcherParam(); @@ -53,12 +54,12 @@ $(document).ready(function () { // Determine where we'd go if clicking on a version selector option function getPageUrlWithVersion(version) { - var currentURL = window.location.href; - var newURL = currentURL.replace(getCurrentVersion(), version); - return encodeURI(newURL); + const currentUrl = window.location.href; + const pattern = new RegExp('(?:http|https)\:\/\/.*?\/'); + const newUrl = currentUrl.match(pattern) + version + '/index.html'; + return encodeURI(newUrl); } - function createSphinxTabSets() { var sphinxTabSets = $('.sphinxtabset'); var tabSetCount = 1000; @@ -131,9 +132,15 @@ function createVersions() { }) var downloadBtn = $('#download-zip-btn'); downloadBtn.attr('href', '/archives/' + currentVersion + '.zip') - } +function updateLanguageSelector() { + const currentVersion = getCurrentVersion(); + $('[aria-labelledby="language-selector"]').find('a').each(function(){ + const newUrl = $(this).attr('href').replace('latest', currentVersion); + $(this).attr('href', newUrl); + }); +} function addTableSort() { var tables = $('table.table'); @@ -318,4 +325,4 @@ function initBenchmarkPickers() { $('#performance-information-frequently-asked-questions section').find('h2').removeClass('expanded'); $('#performance-information-frequently-asked-questions section p, #performance-information-frequently-asked-questions section table').hide(); } - } \ No newline at end of file + }