Merge pull request #20879 from dvdksn/search-urlquery-take2

site: fix search page redirects
This commit is contained in:
David Karlsson 2024-09-13 09:48:46 +02:00 committed by GitHub
commit ab05691edd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -143,11 +143,11 @@
for (let i = 1; i <= resultsLength / 10; i++) {
if (i == currentPage) {
resultsHTML += `<li class="text-center text-white">
<a href="{{ site.BaseURL }}search?q=${query}&page=${i}" class="block h-6 w-6 rounded-sm bg-blue-light dark:bg-blue-dark">${i}</a>
<a href="/search/?q=${query}&page=${i}" class="block h-6 w-6 rounded-sm bg-blue-light dark:bg-blue-dark">${i}</a>
</li>`;
} else {
resultsHTML += `<li class="text-center text-gray-light dark:text-gray-dark">
<a href="{{ site.BaseURL }}search?q=${query}&page=${i}" class="block h-6 w-6 rounded-sm bg-gray-light-200 dark:bg-gray-dark-200">${i}</a>
<a href="/search/?q=${query}&page=${i}" class="block h-6 w-6 rounded-sm bg-gray-light-200 dark:bg-gray-dark-200">${i}</a>
</li>`;
}
}

View File

@ -9,7 +9,7 @@
{{ (resources.Get "images/search-ai.svg").Content | safeHTML }}
<input x-ref="searchBarInput" type="search" id="search-bar-input" @click="open = true" @focus="open = true;"
@blur.window.capture="$refs.searchBarRef.contains($event.relatedTarget) || (open = false);"
@keyup.enter.prevent="window.location.href = '{{ site.BaseURL }}search?q=' + $event.target.value;"
@keyup.enter.prevent="window.location.href = '/search/?q=' + $event.target.value;"
@keyup.escape.prevent="open = false;" @keydown.window="(e) => {
switch(e.key) {
case 'k':
@ -91,7 +91,7 @@
})
.join("");
if (resultsLength > 5) {
resultsHTML += `<div class="w-fit ml-auto px-4 py-2"><a href="/search?q=${query}" class="link">Show all results</a></div>`;
resultsHTML += `<div class="w-fit ml-auto px-4 py-2"><a href="/search/?q=${query}" class="link">Show all results</a></div>`;
}
searchBarResults.innerHTML = resultsHTML;