import { Doc } from "../src/collect.ts"; import { useEffect, useState } from "preact/hooks"; import { Index } from "../src/client_search.ts"; import { encodePath } from "../util/util.ts"; function SearchBar(props: { search?: string; onSearch?: (search: string) => void; }) { const [search, setSearch] = useState(props.search ?? ""); return (
{}} onKeyUp={(event) => { if (event.currentTarget.value === search) return; setSearch(event.currentTarget.value); props.onSearch?.(event.currentTarget.value); }} > {search}
); } export default function DocSearch(props: { docs: Doc[]; }) { const [docs, setDocs] = useState(props.docs); const index = Index.createIndex(props.docs); return ( <> { setDocs(index.search(s)); }} >

Doc

); }