Skip to content

Commit 738d1f8

Browse files
authored
Merge pull request #1906 from Suvink/fix-search-bar
Fix search URL matching conditions
2 parents 7bae012 + 4a884bb commit 738d1f8

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

en/developer-docs/docs/assets/js/choreotheme.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
/*
2020
* Handle opening external links in a new tab
2121
*/
22-
/*
23-
* Initialize highlightjs
22+
/*
23+
* Initialize highlightjs
2424
*/
2525
const form = document.getElementById("search");
2626
const textInput = document.getElementById("query");
@@ -52,17 +52,16 @@ window.addEventListener("DOMContentLoaded", function() {
5252
var pathname = this.window.location.pathname;
5353
var origin = this.window.location.origin;
5454
var searchPage= "search-results.html" + "?search_term=" + searchTerm;
55-
if(pathname != null && pathname.startsWith("/choreo/docs/")){
56-
55+
if(pathname != null && (pathname.startsWith("/choreo/docs/") || pathname === "/choreo/docs")){
56+
5757
searchPage = origin + "/choreo/docs/" + searchPage;
58+
} else if(pathname != null && (pathname.startsWith("/engineering-platform/developer-platform/docs/") || pathname === "/engineering-platform/developer-platform/docs")){
59+
60+
searchPage = origin + "/engineering-platform/developer-platform/docs/" + searchPage;
5861
} else{
5962
searchPage = origin + "/"+ searchPage;
6063
}
6164

62-
// const arrayFromCollection = Array.from(document.links);
63-
// localStorage.setItem('searchResults', arrayFromCollection);
6465
document.location.href=searchPage;
65-
66-
// You can add more code here to handle the form submission
6766
}
6867
});

en/pe-docs/docs/assets/js/choreotheme.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
/*
2020
* Handle opening external links in a new tab
2121
*/
22-
/*
23-
* Initialize highlightjs
22+
/*
23+
* Initialize highlightjs
2424
*/
2525
const form = document.getElementById("search");
2626
const textInput = document.getElementById("query");
@@ -52,17 +52,16 @@ window.addEventListener("DOMContentLoaded", function() {
5252
var pathname = this.window.location.pathname;
5353
var origin = this.window.location.origin;
5454
var searchPage= "search-results.html" + "?search_term=" + searchTerm;
55-
if(pathname != null && pathname.startsWith("/choreo/docs/")){
56-
55+
if(pathname != null && (pathname.startsWith("/choreo/docs/") || pathname === "/choreo/docs")){
56+
5757
searchPage = origin + "/choreo/docs/" + searchPage;
58+
} else if(pathname != null && (pathname.startsWith("/engineering-platform/developer-platform/docs/") || pathname === "/engineering-platform/developer-platform/docs")){
59+
60+
searchPage = origin + "/engineering-platform/developer-platform/docs/" + searchPage;
5861
} else{
5962
searchPage = origin + "/"+ searchPage;
6063
}
6164

62-
// const arrayFromCollection = Array.from(document.links);
63-
// localStorage.setItem('searchResults', arrayFromCollection);
6465
document.location.href=searchPage;
65-
66-
// You can add more code here to handle the form submission
6766
}
6867
});

0 commit comments

Comments
 (0)