Skip to content

Commit fa1d647

Browse files
committed
js/search: make search a no-op if algolia environment variables are not set
Signed-off-by: Ruby Iris Juric <[email protected]>
1 parent c0b86f4 commit fa1d647

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

source/assets/js/search.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ function processResult(result) {
4949
}
5050

5151
function Search(config) {
52+
if (!config.appId || !config.apiKey || !config.prefix) {
53+
console.warn("Algolia environment variables not configured - search disabled");
54+
return;
55+
}
56+
5257
this.client = new AlgoliaSearch(config.appId, config.apiKey);
5358
this.prefix = config.prefix;
5459
this.searchNumber = 0;
@@ -98,6 +103,8 @@ Search.indexes = {
98103
};
99104

100105
Search.prototype.search = function (query) {
106+
if (!this.client) return;
107+
101108
if (query === this.lastQuery) {
102109
return;
103110
}

0 commit comments

Comments
 (0)