mirror of
https://github.com/ershisan99/DevToysWeb.git
synced 2025-12-16 12:32:48 +00:00
perf: speed up search
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useSearchText } from "@/contexts/search-text";
|
||||
import Fuse from "fuse.js";
|
||||
|
||||
import { homeTools } from "@/config/tools";
|
||||
@@ -8,9 +8,8 @@ import { PageRootSection } from "@/components/page-root-section";
|
||||
import { ToolCards } from "@/components/tool-cards";
|
||||
|
||||
export default function Page() {
|
||||
const params = useSearchParams();
|
||||
|
||||
const q = params.get("q")?.trim() ?? "";
|
||||
// use search params in context
|
||||
const q = useSearchText();
|
||||
|
||||
const fuse = new Fuse(homeTools, { keys: ["keywords"], threshold: 0.45 });
|
||||
const keyWordsOptions = q.split(" ").map(word => ({ keywords: word }));
|
||||
|
||||
Reference in New Issue
Block a user