Rank changelog results to the very bottom

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
This commit is contained in:
Johannes Marbach 2026-05-22 12:38:14 +02:00
parent 5fa9103ae5
commit 78ab248a0b
2 changed files with 12 additions and 4 deletions

View file

@ -132,18 +132,26 @@ search backend.
// Kick off the search, load the results and inject them into the popover.
//
const search = await pagefind.debouncedSearch(searchQuery);
// First search all non-changelog pages.
const search = await pagefind.debouncedSearch(searchQuery, { filters: { not: { type: "changelog" } } });
if (search === null) {
// A more recent search call has been made, nothing to do.
return;
}
if (search.results.length === 0) {
// Now search the changelog pages and append any results so that changelog
// results are ranked lowest. We cannot use Pagefind's sorting to do this
// because that would override the default ranking within the non-changelog
// results
const changelogSearch = await pagefind.search(searchQuery, { filters: { type: "changelog" } });
const results = [...search.results, ...changelogSearch.results];
if (results.length === 0) {
$searchResultBody.append(
$("<p>").text(`No results found for query "${searchQuery}"`)
);
} else {
await loadAndRenderResults(search.results, 0, $spinner, $searchResultBody);
await loadAndRenderResults(results, 0, $spinner, $searchResultBody);
}
};
});

View file

@ -16,7 +16,7 @@
{{ define "main" }}
{{ $version := lower .LinkTitle -}}
<div class="td-content">
<div class="td-content" data-pagefind-filter="type:changelog">
<h1>{{ .Title }}</h1>
<table class="release-info">