1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /*
- * Init search engine and index.
- */
- async function get_json(url) {
- try {
- const response = await fetch(url);
- if (!response.ok) {
- throw new Error(`Response status: ${response.status}`);
- }
- const json = await response.json();
- console.log(json);
- return json;
- } catch (error) {
- console.error(error.message);
- }
- }
- async function fuse_init() {
- let [idx_json, keys_json] = await Promise.all([
- get_json('/js/fuse_index.json'),
- get_json('/js/fuse_keys.json')
- ]);
- const fuseOptions = {
- // isCaseSensitive: false,
- // includeScore: false,
- // ignoreDiacritics: false,
- // shouldSort: true,
- // includeMatches: false,
- // findAllMatches: false,
- // minMatchCharLength: 1,
- // location: 0,
- // threshold: 0.6,
- // distance: 100,
- // useExtendedSearch: false,
- // ignoreLocation: false,
- // ignoreFieldNorm: false,
- // fieldNormWeight: 1,
- keys: keys_json,
- };
- return new Fuse(idx_json, fuseOptions);
- }
|