 endpoint = '{{ "/assets/search.json" | relative_url }}';

    const pages = [];

    fetch(endpoint)
        .then(blob => blob.json())
        .then(data => pages.push(...data))

    function findResults(termToMatch, pages) {
        return pages.filter(item => {
            const regex = new RegExp(termToMatch, 'gi');
            return item.title.match(regex) || item.content.match(regex);
        });
    }

    function displayResults() {
        const resultsArray = findResults(this.value, pages);
    