diff --git a/assets/scripts/pages/search.js b/assets/scripts/pages/search.js index c7b7b73..cd5eb08 100644 --- a/assets/scripts/pages/search.js +++ b/assets/scripts/pages/search.js @@ -26,7 +26,7 @@ window.addEventListener('DOMContentLoaded', () => { const searchQuery = param('keyword') if (searchQuery) { - document.getElementById('search-query').value = searchQuery + document.getElementById('search-box').value = searchQuery executeSearch(searchQuery) } else { const node = document.createElement('p') @@ -37,7 +37,7 @@ window.addEventListener('DOMContentLoaded', () => { function executeSearch (searchQuery) { const url = window.location.href.split('/search/')[0] + '/index.json' - fetch(url).then(function (data) { + fetch(url).then(response => response.json()).then(function (data) { const pages = data const fuse = new Fuse(pages, fuseOptions) const results = fuse.search(searchQuery) @@ -91,8 +91,8 @@ window.addEventListener('DOMContentLoaded', () => { snippet }) - const doc = new DOMParser().parseFromString(output, 'text/html') - document.getElementById('search-results').append(doc) + const dom = new DOMParser().parseFromString(output, 'text/html') + document.getElementById('search-results').append(dom.getElementsByClassName('post-card')[0]) snippetHighlights.forEach(function (snipvalue) { const context = document.getElementById('#summary-' + key) diff --git a/assets/styles/layouts/list.scss b/assets/styles/layouts/list.scss index 717cc74..d79b7eb 100644 --- a/assets/styles/layouts/list.scss +++ b/assets/styles/layouts/list.scss @@ -1,7 +1,7 @@ // in Hugo, Page kind can be either "section" or "page". // if it is section, then it's a page with a list of items, for example /posts // if it is page, then it is a single page. -body.kind-section, body.kind-term { +body.kind-section, body.kind-term, body.kind-page{ .wrapper { display: flex; padding: 0;