Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit bd1203b

Browse files
committed
Fix url creation
1 parent 2a5bf4a commit bd1203b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

_templates/banner.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
if (path.includes('/' + lang + '/')) {
144144
$(this).addClass('active-lang').css({
145145
"font-weight": "bold",
146-
"color": "white"
146+
"color": "red"
147147
});
148148
} else {
149149
$(this).removeClass('active-lang').removeAttr('style');
@@ -153,9 +153,23 @@
153153

154154
setActiveLanguage();
155155

156+
function constructNewPath(lang) {
157+
var currentPath = window.location.pathname;
158+
var pathSegments = currentPath.split('/');
159+
var langIndex = pathSegments.findIndex(segment => $('.lang').map(function() { return $(this).data('lang'); }).get().includes(segment));
160+
161+
if (langIndex > -1) {
162+
pathSegments[langIndex] = lang;
163+
} else {
164+
pathSegments.splice(1, 0, lang);
165+
}
166+
167+
return pathSegments.join('/');
168+
}
169+
156170
$('.lang').click(function() {
157171
var lang = $(this).data('lang');
158-
var newPath = '/observability/' + lang + '/';
172+
var newPath = constructNewPath(lang);
159173
window.location.pathname = newPath;
160174

161175
setActiveLanguage();

0 commit comments

Comments
 (0)