fix(blog): make featured article respect search match

The featured article previously hid whenever a query was active,
regardless of whether it matched. Treat it as a normal [data-search]
row instead: visible iff it matches the query, and counted toward
visibleCount so a featured-only match no longer triggers the
"no entries match" message.

Closes the follow-up at
docs/superpowers/follow-ups/2026-06-02-blog-search-featured-match.md
and updates the design spec to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Josh Bairstow 2026-06-02 12:48:35 +10:00
parent 82e5ff6309
commit 0a5a7d5e45
2 changed files with 6 additions and 14 deletions

View file

@ -88,7 +88,6 @@
const rows = Array.from(
document.querySelectorAll<HTMLElement>("[data-search]")
);
const featured = document.querySelector<HTMLElement>("[data-featured]");
const yearHeads = Array.from(
document.querySelectorAll<HTMLElement>("[data-year-head]")
);
@ -103,18 +102,11 @@
let visibleCount = 0;
for (const row of rows) {
const haystack = row.dataset.search ?? "";
const isFeatured = row === featured;
let visible: boolean;
if (!isFiltering) {
visible = true;
} else if (isFeatured) {
// Featured hides whenever there's a query, regardless of match.
visible = false;
} else {
visible = tokens.every((t) => haystack.includes(t));
}
// The featured article is just another [data-search] row: it's
// visible iff it matches the query, same as every archive row.
const visible = !isFiltering || tokens.every((t) => haystack.includes(t));
row.classList.toggle("is-hidden", !visible);
if (visible && !isFeatured) visibleCount += 1;
if (visible) visibleCount += 1;
}
// Hide year heads whose following rows are all hidden.