Skip to content

Commit 0a36f57

Browse files
authored
Fix docs search box disappearing on navigation (#1796)
1 parent ed52608 commit 0a36f57

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

resources/js/docsearch.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ let hotKeys = [
99
"/",
1010
];
1111

12-
docsearch({
13-
container: "#docsearch",
14-
host: "https://search.statamic.dev",
15-
apiKey: "a8b8f82076221f9595dceca971be29c36cbccd772de5dbdb7f43dfac41557f95",
16-
indexUid: `docs-${import.meta.env.VITE_STATAMIC_DOCS_VERSION}`,
17-
hotKeys: hotKeys,
18-
});
12+
function initDocsearch() {
13+
const container = document.querySelector("#docsearch");
14+
if (!container || container.childElementCount > 0) return;
15+
16+
docsearch({
17+
container: "#docsearch",
18+
host: "https://search.statamic.dev",
19+
apiKey: "a8b8f82076221f9595dceca971be29c36cbccd772de5dbdb7f43dfac41557f95",
20+
indexUid: `docs-${import.meta.env.VITE_STATAMIC_DOCS_VERSION}`,
21+
hotKeys: hotKeys,
22+
});
23+
}
24+
25+
initDocsearch();
26+
document.addEventListener("livewire:navigated", initDocsearch);

0 commit comments

Comments
 (0)