diff options
Diffstat (limited to 'static/js/search.js')
-rw-r--r-- | static/js/search.js | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/static/js/search.js b/static/js/search.js deleted file mode 100644 index 62bcbbb..0000000 --- a/static/js/search.js +++ /dev/null @@ -1,27 +0,0 @@ -fetch('/index.json') - .then(response => response.json()) - .then(data => { - const fuse = new Fuse(data, { - keys: ['title', 'contents', 'tags'], - includeScore: true - }); - document.getElementById('search-input').addEventListener('input', function (e) { - const results = fuse.search(e.target.value); - displayResults(results); - }); - }); - -function displayResults(results) { - const searchResults = document.getElementById('search-results'); - searchResults.innerHTML = ''; - if (results.length > 0) { - searchResults.classList.remove("hidden"); - } else { - searchResults.classList.add("hidden"); - } - results.forEach(result => { - const elem = document.createElement('div'); - elem.innerHTML = `<a class="list-group-item list-group-item-action" href="${result.item.permalink}">${result.item.title}</a></a`; - searchResults.appendChild(elem); - }); -} |