Skip to content

Commit

Permalink
Fix document search shows pages that are not selected (#4453)
Browse files Browse the repository at this point in the history
Signed-off-by: Kenta Kozuka <[email protected]>
  • Loading branch information
kentakozuka authored Jun 28, 2023
1 parent 7cc4733 commit 0fa58ad
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/assets/js/offline-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
return false;
});

// Get selected version from dropdown.
var siteDocsVersion = document.getElementById('navbarDropdown');

//
// Lunr
//
Expand All @@ -50,6 +53,12 @@
this.field('body');

data.forEach((doc) => {
// Skip pages that are not the selected version.
if(
doc.ref.startsWith('/docs-') &&
!doc.ref.startsWith(`/docs-${siteDocsVersion?.textContent?.trim()}`)) {
return;
}
this.add(doc);

resultDetails.set(doc.ref, {
Expand Down

0 comments on commit 0fa58ad

Please sign in to comment.