From 1393664992d5cc98a9e2bfb7b9e7bf797c3611be Mon Sep 17 00:00:00 2001 From: kamijin_fanta Date: Tue, 3 Dec 2024 17:04:20 +0900 Subject: [PATCH] preview: Reduce the number of results displayed in search results (#997) --- .../src/components/search/search-iconset.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/preview-astro/src/components/search/search-iconset.tsx b/packages/preview-astro/src/components/search/search-iconset.tsx index f4faacf66..ac72e1a75 100644 --- a/packages/preview-astro/src/components/search/search-iconset.tsx +++ b/packages/preview-astro/src/components/search/search-iconset.tsx @@ -30,13 +30,18 @@ export function SearchIconSet({ const found = icons && - Object.keys(icons).filter((name) => - query - .toLowerCase() - .split(" ") - .filter((t) => !!t) - .every((term) => name.toLowerCase().includes(term)), - ); + Object.keys(icons) + .filter((name) => { + const rules = query + .toLowerCase() + .split(" ") + .filter((t) => !!t); + return rules.length == 0 + ? false + : rules.every((term) => name.toLowerCase().includes(term)); + }) + .slice(0, 100); // show top 100 icons + return ( <> {found ? (