Skip to content

Commit 3692c56

Browse files
authored
Combine latest and 5.0 entries in the switcher (#369)
* Combine latest and 5.0 entries in the switcher * Fixed
1 parent 2003936 commit 3692c56

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/js/custom.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
let jquery = jQuery;
33

44
$(document).ready(function() {
5+
const latestVersionNumber = '5.0';
6+
57
// replace edit url
68
let branchName = 'master';
79
const branchNameRegexp = /\/en\/([a-z0-9-_.]*)\//g.exec(document.location.href);
@@ -63,6 +65,15 @@ $(document).ready(function() {
6365
$(this).detach().prependTo(vl);
6466
});
6567
}
68+
69+
// Merge "X.Y" and "latest" entries into "X.Y (latest)"
70+
const allVersions = [...document.querySelectorAll('.switcher__list .versions dd')];
71+
const latestVersion = allVersions.find(v => v.textContent.trim() === 'latest');
72+
const versionXY = allVersions.find(v => v.textContent.trim() === latestVersionNumber);
73+
74+
const versionXYLink = versionXY.querySelector('a');
75+
versionXYLink.textContent = `${latestVersionNumber} (latest)`;
76+
latestVersion.remove();
6677
}
6778
}, 300);
6879
setTimeout(function() {

0 commit comments

Comments
 (0)