www: add search button island (#949)

This commit is contained in:
Luca Casonato
2022-12-23 04:19:50 +09:00
committed by GitHub
parent 026c1affd7
commit c291db8ac4
8 changed files with 93 additions and 10 deletions
+28
View File
@@ -0,0 +1,28 @@
import { Head } from "$fresh/runtime.ts";
import { useEffect, useRef } from "preact/hooks";
import docsearch from "https://esm.sh/@docsearch/js@3";
export default function SearchButton() {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (ref.current) {
docsearch({
appId: "CWUS37S0PK",
apiKey: "caa591b6dcb2c9308551361d954a728b",
indexName: "fresh",
container: ref.current,
});
}
}, [ref.current]);
return (
<>
<Head>
<link
rel="stylesheet"
href="/docsearch.css"
/>
</Head>
<div class="h-9 mb-6" ref={ref}></div>
</>
);
}