docs: fix regression in navigation (#2047)

This commit is contained in:
Marvin Hagemeister
2023-11-16 10:38:13 +01:00
committed by GitHub
parent 93c17b7184
commit 7578e50ee3
4 changed files with 48 additions and 36 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
import { Head } from "$fresh/runtime.ts";
import { useEffect, useRef } from "preact/hooks";
import docsearch from "https://esm.sh/@docsearch/js@3.5.2?target=es2020";
// Copied from algolia source code
type DocSearchProps = {
@@ -10,12 +11,12 @@ type DocSearchProps = {
};
export default function SearchButton(
props: { docsearch: (args: DocSearchProps) => void; class?: string },
props: { docsearch?: (args: DocSearchProps) => void; class?: string },
) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (ref.current) {
props.docsearch({
props.docsearch || docsearch({
appId: "CWUS37S0PK",
apiKey: "caa591b6dcb2c9308551361d954a728b",
indexName: "fresh",