(async function () { // Load the pre-processed data from the json file let postsPromise = fetch('/posts.json'); let indexPromise = fetch('/lunr-index.json'); let [postsResponse, indexResponse] = await Promise.all([postsPromise, indexPromise]); let [postsData, indexData] = await Promise.all([postsResponse.json(), indexResponse.json()]); let lunrIndex = lunr.Index.load(indexData); let posts = postsData; document.getElementById('Search').classList.remove('u-hidden'); // From: https://davidwalsh.name/function-debounce const debounce = (func, wait, immediate) => { let timeout; return function () { let context = this; let args = arguments; let later = function () { timeout = null; if (!immediate) func.apply(context, args); }; let callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; }; const writeToPage = html => document.getElementById('SearchResults').innerHTML = html; const createTitleBox = text => { return `
${text}
${post.description}
` : ''; return `