in themes/docsy/static/js/offline-search.js [20:45]
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
// Success response received in requesting the search-index file
var searchDocuments = JSON.parse(request.responseText);
// Build the index so Lunr can search it. The `ref` field will hold the URL
// to the page/post. title, excerpt, and body will be fields searched.
idx = lunr(function lunrIndex() {
this.ref('ref');
this.field('title');
this.field('body');
// Loop through all the items in the JSON file and add them to the index
// so they can be searched.
searchDocuments.forEach(function(doc) {
this.add(doc);
resultDetails[doc.ref] = {
'title': doc.title,
'excerpt': doc.excerpt,
};
}, this);
});
} else {
$searchResults.innerHTML = '<ul><li>Error loading search results</li></ul>';
}
};