From f93d18e3e5171a5a29a3f6c9b086a2f7e81dc47d Mon Sep 17 00:00:00 2001 From: Ben Fornefeld Date: Fri, 10 Jan 2025 23:32:42 +0100 Subject: [PATCH] add: sort legacy docs search results at last + improve: docs search legacy badge --- apps/web/src/components/Search.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/Search.tsx b/apps/web/src/components/Search.tsx index 858499033..8e1ac9c15 100644 --- a/apps/web/src/components/Search.tsx +++ b/apps/web/src/components/Search.tsx @@ -83,7 +83,12 @@ function useAutocomplete({ close }: { close: () => void }) { { sourceId: 'documentation', getItems() { - return search(query, { limit: 5 }) + const results = search(query, { limit: 5 }) + return results.sort((a, b) => { + if (a.badge === 'Legacy' && b.badge !== 'Legacy') return 1 + if (a.badge !== 'Legacy' && b.badge === 'Legacy') return -1 + return 0 + }) }, getItemUrl({ item }) { return item.url @@ -210,7 +215,7 @@ function SearchResult({ return (
  • 0 && 'border-t border-zinc-100 dark:border-zinc-800' )} aria-labelledby={`${id}-hierarchy ${id}-title`} @@ -255,7 +260,7 @@ function SearchResult({ )} {result.badge === 'Legacy' && (
    - + {result.badge}