fetch('/search_index.json') .then(r => r.json()) .then(data => { const idx = elasticlunr.Index.load(data); const docs = idx.documentStore.docs; const searchInput = document.getElementById('search'); const out = document.getElementById('searchResults'); const filterSelect = document.getElementById('searchMode'); function runSearch(q, tags = 'all') { let result = idx.search(q, { expand: true }).map(r => docs[r.ref] ) if (tags === 'all') { return result; } result = result.filter(d => tags === 'all' || d.tags.includes(tags)); return result; } function render(doc) { console.log(doc.imageq) let tagsHTML = ""; console.log(doc.tags) doc.tags.forEach(tag => { tagsHTML += `
${doc.image ? `` : ''} ${doc.title}${doc.author ? ` by ${doc.author}` : ''}
${doc.subtitle}