Skip to content

Commit ac6280d

Browse files
authored
fix: docsearch (#984)
1 parent f278e9f commit ac6280d

File tree

2 files changed

+4
-49
lines changed

2 files changed

+4
-49
lines changed

docusaurus.config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ const algolia = isCN
2222
appId: "FUCSAUXK2Q",
2323
apiKey: "0f200c10999f19584ec9e31b5caa9065",
2424
indexName: "databend",
25-
contextualSearch: true,
25+
contextualSearch: true
2626
}
2727
: {
2828
appId: "XA8ZCKIEYU",
2929
apiKey: "81e5ee11f82ed1c5de63ef7ea0551abf",
3030
indexName: "databend",
31-
contextualSearch: true,
31+
contextualSearch: false
3232
};
3333

3434
const config: Config = {
@@ -74,7 +74,6 @@ const config: Config = {
7474
docsHomeLink,
7575
homeLink,
7676
cloudLink,
77-
algolia,
7877
blogTags: ["weekly", "databend"],
7978
askBendUrl: isProduction ? ASKBEND_URL : "",
8079
},
@@ -213,7 +212,7 @@ const config: Config = {
213212
themeConfig: {
214213
// Replace with your project's social card
215214
image: "img/logo/logo-no-text.png",
216-
// algolia,
215+
algolia,
217216
imageZoom: {
218217
selector: "article :not(a) > img",
219218
},

src/theme/Footer/index.tsx

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7-
import React, { useEffect } from "react";
7+
import React from "react";
88
import clsx from "clsx";
99
import Head from "@docusaurus/Head";
1010
import useBaseUrl from "@docusaurus/useBaseUrl";
@@ -14,60 +14,16 @@ import CookiesConsent from "../../components/CookiesConsent";
1414
import styles from "./index.module.scss";
1515
import * as icons from "../../components/Icons";
1616
import RedirectComponent from "@site/src/components/RedirectComponent";
17-
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
18-
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
1917
// import ProgressBar from "react-scroll-progress-bar";
2018

2119
const GLOBAL_SEARCH_ID = "GLOBAL-ID-SEARCH-229";
2220
function Footer() {
2321
const year = new Date().getFullYear();
2422
const { footer } = useThemeConfig();
25-
const {
26-
siteConfig: {
27-
customFields: { algolia },
28-
},
29-
} = useDocusaurusContext();
30-
useEffect(() => {
31-
const id = document.getElementById(GLOBAL_SEARCH_ID);
32-
if (!id) {
33-
const script = document.createElement("script");
34-
script.id = GLOBAL_SEARCH_ID;
35-
script.src = "https://cdn.jsdelivr.net/npm/@docsearch/js@3";
36-
script.async = true;
37-
script.onload = () => {
38-
setSearch();
39-
};
40-
document.body.appendChild(script);
41-
} else {
42-
setSearch();
43-
}
44-
45-
function setSearch() {
46-
if (ExecutionEnvironment.canUseDOM) {
47-
const container = document.querySelector(
48-
'[class^="navbarSearchContainer"]'
49-
);
50-
try {
51-
if (window.docsearch) {
52-
window.docsearch({
53-
...(algolia as any),
54-
container,
55-
});
56-
}
57-
} catch (error) {
58-
console.log(error);
59-
}
60-
}
61-
}
62-
}, []);
6323
return (
6424
<footer className={clsx("footer", styles.footer)}>
6525
<Head>
6626
<script async src={useBaseUrl("/Koala/index.js")}></script>
67-
<link
68-
rel="stylesheet"
69-
href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"
70-
/>
7127
</Head>
7228
<div className={clsx("footer-items", styles.footerItems)}>
7329
{(footer.links[0].items as any[])?.map((item, index) => {

0 commit comments

Comments
 (0)