Skip to content

Commit 0c22759

Browse files
committed
flexsearch: attempt to fix search in prod
1 parent 70ce372 commit 0c22759

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

assets/js/flexsearch.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Patch Doks' builtin flexsearch implementation so that it resolves the search index correctly when deployed to a
22
// subdirectory. Original code: https://github.com/gethyas/doks-core/blob/main/assets/js/flexsearch.js.
33
//
4-
// The only line changed compared to the original code above is L133; see comment there.
4+
// The only line changed compared to the original code above is L134; see comment there.
55

66
/*!
77
* FlexSearch for Bootstrap based Hyas sites
@@ -129,8 +129,9 @@ import Index from 'flexsearch';
129129
function buildIndex() {
130130
document.querySelector('.search-loading').classList.remove('d-none');
131131

132-
// Originally `fetch("{{ site.LanguagePrefix }}/search-index.json")`; our patch prefixes with {{ site.BaseURL }}.
133-
fetch("{{ site.BaseURL }}{{ site.LanguagePrefix }}/search-index.json")
132+
// Originally `fetch("{{ site.LanguagePrefix }}/search-index.json")`; our patch resolves the search index relative
133+
// to the base URL of the deployment.
134+
fetch("{{ relURL `search-index.json` }}")
134135
.then(function (response) {
135136
return response.json();
136137
})

0 commit comments

Comments
 (0)