diff --git a/apps/website/src/app/(playgrounds)/playgrounds/playground-card-list.tsx b/apps/website/src/app/(playgrounds)/playgrounds/playground-card-list.tsx index 88ba84c..fd53379 100644 --- a/apps/website/src/app/(playgrounds)/playgrounds/playground-card-list.tsx +++ b/apps/website/src/app/(playgrounds)/playgrounds/playground-card-list.tsx @@ -13,7 +13,6 @@ import { import { Separator } from '@evaluate/components/separator'; import { toast } from '@evaluate/components/toast'; import type { PartialRuntime } from '@evaluate/shapes'; -import Fuse from 'fuse.js'; import { ArrowDownWideNarrowIcon, CircleDotIcon, @@ -33,16 +32,27 @@ export function PlaygroundCardList({ }) { const [search, setSearch] = useQueryParameter('search'); const deferredSearch = useDeferredValue(search); - const searchEngine = useMemo(() => { - return new Fuse(initialRuntimes, { - keys: ['name', 'aliases', 'tags'], - threshold: 0.3, - }); - }, [initialRuntimes]); const searchedRuntimes = useMemo(() => { if (!deferredSearch) return initialRuntimes; - return searchEngine.search(deferredSearch).map((result) => result.item); - }, [initialRuntimes, deferredSearch, searchEngine]); + + return initialRuntimes.filter((runtime) => { + if (runtime.name.toLowerCase().includes(deferredSearch.toLowerCase())) + return true; + if ( + runtime.aliases.some((alias) => + alias.toLowerCase().includes(deferredSearch.toLowerCase()), + ) + ) + return true; + if ( + runtime.tags.some((tag) => + tag.toLowerCase().includes(deferredSearch.toLowerCase()), + ) + ) + return true; + return false; + }); + }, [initialRuntimes, deferredSearch]); type SortBy = 'popularity' | 'name'; const [sortBy, setSortBy] = useQueryParameter('sort', 'popularity'); diff --git a/apps/website/tsconfig.json b/apps/website/tsconfig.json index 6192938..e80ac31 100644 --- a/apps/website/tsconfig.json +++ b/apps/website/tsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "incremental": true, "plugins": [{ "name": "next" }], - "strictNullChecks": true + "strictNullChecks": true, + "paths": { "~/*": ["./src/*"] } } } diff --git a/packages/engine/src/runtimes/fetch.ts b/packages/engine/src/runtimes/fetch.ts index 2d308c5..47d5754 100644 --- a/packages/engine/src/runtimes/fetch.ts +++ b/packages/engine/src/runtimes/fetch.ts @@ -65,7 +65,7 @@ export async function searchRuntimes(...queries: string[]) { const runtimes = await fetchRuntimes(); const keys = ['name', 'aliases', 'tags']; - const fuse = new Fuse(runtimes, { keys, threshold: 0.3 }); + const fuse = new Fuse(runtimes, { keys, threshold: 0.35 }); return queries .flatMap((q) => fuse.search(q).map((r) => r.item))