Skip to content

Commit 23a6642

Browse files
committed
Update search.js to use new pre-combined indexes; Support for running search on local docs
1 parent 4d26818 commit 23a6642

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

js/search.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const initPHPSearch = async (language) => {
2020
const key = `search2-${language}`;
2121
const cache = window.localStorage.getItem(key);
2222

23-
if (!cache) {
23+
if ((!cache) || (language === 'local')) {
2424
return null;
2525
}
2626

@@ -48,20 +48,20 @@ const initPHPSearch = async (language) => {
4848
} else {
4949
const response = await fetch(`/js/search-index.php?lang=${language}`);
5050
items = await response.json();
51-
}
5251

53-
try {
54-
localStorage.setItem(
55-
key,
56-
JSON.stringify({
57-
data: items,
58-
time: Date.now(),
59-
}),
60-
);
61-
} catch (e) {
62-
// Local storage might be full, or other error.
63-
// Just continue without caching.
64-
console.error("Failed to cache search index", e);
52+
try {
53+
localStorage.setItem(
54+
key,
55+
JSON.stringify({
56+
data: items,
57+
time: Date.now(),
58+
}),
59+
);
60+
} catch (e) {
61+
// Local storage might be full, or other error.
62+
// Just continue without caching.
63+
console.error("Failed to cache search index", e);
64+
}
6565
}
6666

6767
return items;

0 commit comments

Comments
 (0)