Commit e1b7eca7 authored by Tom Behets's avatar Tom Behets
Browse files

feat(search): group events to top of results, sorted newest first

Both runtimes (sidebar dropdown and /search/ page) now partition matches
into events vs everything else, sort the events block by startdate
descending (ISO YYYY-MM-DD strings sort lexicographically the same as
chronologically), and concatenate events first then non-events. Inside
each block, Fuse relevance order is preserved.

Also: add .worktrees_backup to .gitignore. Stale build artifacts from
the prior site-search mission's worktree had been getting picked up by
git add -A on each follow-up commit.

Co-Authored-By: default avatarClaude Opus 4.7 (1M context) <noreply@anthropic.com>
parent d34f9fc8
Loading
Loading
Loading
Loading
+2
Changes for .gitignore: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -39,3 +39,5 @@
.kittify/runtime/
.kittify/workspaces/
.worktrees
.worktrees_backup
.worktrees_backup/
+20
Changes for static/js/sidebar-search.js: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -155,6 +155,26 @@
    if (hits.length === 0) {
      return;
    }

    // Group events to the top, sorted by startdate descending (newest
    // first). Non-events keep their Fuse relevance order. ISO YYYY-MM-DD
    // sorts lexicographically the same as chronologically.
    var eventHits = [];
    var otherHits = [];
    hits.forEach(function (h) {
      if (h.item && h.item.section === "events") {
        eventHits.push(h);
      } else {
        otherHits.push(h);
      }
    });
    eventHits.sort(function (a, b) {
      var da = (a.item && a.item.startdate) || "";
      var db = (b.item && b.item.startdate) || "";
      return db < da ? -1 : (db > da ? 1 : 0);
    });
    hits = eventHits.concat(otherHits);

    hits.forEach(function (hit) {
      var entry = hit.item;
      var li    = document.createElement("li");
+19
Changes for static/js/site-search.js: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -153,6 +153,25 @@
      rows.push(toResultRow(entry, q, hit.matches));
    });

    // Group events to the top of the list, sorted by startdate descending
    // (newest first). Non-events keep their Fuse relevance order. ISO
    // YYYY-MM-DD strings sort lexicographically the same as chronologically.
    var eventRows = [];
    var otherRows = [];
    rows.forEach(function (r) {
      if (r.section === "events") {
        eventRows.push(r);
      } else {
        otherRows.push(r);
      }
    });
    eventRows.sort(function (a, b) {
      var da = a.startdate || "";
      var db = b.startdate || "";
      return db < da ? -1 : (db > da ? 1 : 0);
    });
    rows = eventRows.concat(otherRows);

    state.lastResults = rows;
    state.phase = "ready";
    applyFilterAndRender();