diff --git a/src/components/core/Search.tsx b/src/components/core/Search.tsx index 2c358e0..f8faf62 100644 --- a/src/components/core/Search.tsx +++ b/src/components/core/Search.tsx @@ -18,7 +18,18 @@ import { Search as SearchIcon } from "lucide-react"; import type { DocsEntry } from "@/lib/types"; import { capitalizeFirstLetter } from "@/lib/utils"; -import { menu_items } from "config"; + +function extractHeaders(body: string): string[] { + const headers = []; + const lines = body.split("\n"); + for (const line of lines) { + const match = line.match(/^(#{1,6})\s+(.*)/); + if (match) { + headers.push(match[2]); + } + } + return headers; +} const docs: DocsEntry[] = await getCollection("docs"); @@ -50,6 +61,11 @@ const options: IFuseOptions = { weight: 1.5, getFn: (docs: DocsEntry) => docs.data.tags.join(" ") || "", }, + { + name: "headers", + weight: 2, + getFn: (docs: DocsEntry) => extractHeaders(docs.body).join(" "), + }, ], }; @@ -74,8 +90,6 @@ export function Search() { return () => document.removeEventListener("keydown", down); }, []); - console.log(results); - return (