diff --git a/app/components/Search.telefunc.ts b/app/components/Search.telefunc.ts deleted file mode 100644 index 8cf575b..0000000 --- a/app/components/Search.telefunc.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { buildFlexSearch } from "@/services/FlexSearchService"; -import { docCache } from "@/services/DocCache"; - -export const onSearch = async (query: string) => { - const docs = docCache.fetchDocs(); - const search = buildFlexSearch(docs); - - return search(query, 5); -}; diff --git a/app/components/Search.tsx b/app/components/Search.tsx index 25be473..f2f2658 100644 --- a/app/components/Search.tsx +++ b/app/components/Search.tsx @@ -8,9 +8,11 @@ import { createEffect, createSignal, } from "solid-js"; -import { Dialog, DialogPanel } from "terracotta"; -import { useDebounce } from "@/hooks/useDebounce"; + import { Highlighter } from "solid-highlight-words"; +import { useDebounce } from "@/hooks/useDebounce"; +import { Dialog, DialogPanel } from "terracotta"; +import { navigation } from "@/libs/navigation"; import { navigate } from "vike/client/router"; import { useId } from "@/hooks/useId"; import clsx from "clsx"; @@ -127,6 +129,18 @@ function SearchResultItem(props: { result: SearchResult; query: string }) { const { close } = useContext(SearchContext); const id = useId(); + const getHierarchy = (): string[] => { + const sectionTitle = navigation.find((section) => { + return section.links.find( + (link) => link.href === props.result.url.split("#")[0], + ); + })?.title; + + return [sectionTitle, props.result.pageTitle].filter( + (x): x is string => typeof x === "string", + ); + }; + return (