diff --git a/_includes/components/search_header.html b/_includes/components/search_header.html index e5870464..24ddf529 100644 --- a/_includes/components/search_header.html +++ b/_includes/components/search_header.html @@ -1,11 +1,24 @@ - diff --git a/assets/js/wp-a11y-docs.js b/assets/js/wp-a11y-docs.js index b9747b66..70b9e9d5 100644 --- a/assets/js/wp-a11y-docs.js +++ b/assets/js/wp-a11y-docs.js @@ -88,6 +88,9 @@ function initSearch() { }); searchLoaded(index, docs); + window.jtdSearchIndex = index; + window.jtdSearchDocs = docs; + } else { console.log('Error loading ajax request. Request status:' + request.status); } @@ -429,11 +432,12 @@ function searchLoaded(index, docs) { var active = document.querySelector('.search-result.active'); if (active) { active.click(); - } else { - var first = document.querySelector('.search-result'); - if (first) { - first.click(); - } + } + else { + var inputValue = searchInput.value.trim(); + if (inputValue.length > 0) { + window.location.href = '/search/?q=' + encodeURIComponent(inputValue); + } } return; } @@ -560,3 +564,43 @@ jtd.onReady(function(){ }); })(window.jtd = window.jtd || {}); + +// --------------------------- +// Full Search Results Page +// --------------------------- +document.addEventListener("DOMContentLoaded", function () { + const urlParams = new URLSearchParams(window.location.search); + const query = urlParams.get("q"); + + if (query) { + const resultsContainer = document.getElementById("search-results-page"); + if (resultsContainer) { + // Ensure index and docs exist + if (window.jtdSearchIndex && window.jtdSearchDocs) { + const index = window.jtdSearchIndex; + const docs = window.jtdSearchDocs; + + let results = index.search(query); + + if (results.length > 0) { + resultsContainer.innerHTML = ` +

${results.length} results found for "${query}"

+ + `; + } else { + resultsContainer.innerHTML = `

No results found for "${query}".

`; + } + } + } + } +}); + diff --git a/search.html b/search.html new file mode 100644 index 00000000..ca293b72 --- /dev/null +++ b/search.html @@ -0,0 +1,8 @@ +--- +layout: default +title: Search Results +--- +

Search Results

+
+

Loading search results…

+