-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathSearch.js
63 lines (58 loc) · 1.33 KB
/
Search.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from "react";
// TODO: Inject api keys in a smarter way
const Search = ({ sectionName }) => {
let appId = null;
let apiKey = null;
let indexName = null;
if (sectionName === "react") {
appId = "1A2L5TW6MQ";
apiKey = "90734373e2b9273836fb9054fac308cf";
indexName = "survivejs_react";
} else if (sectionName === "maintenance") {
appId = "QD8ZTJ41U9";
apiKey = "f420895920e526e0cb84df1ce0a27f90";
indexName = "survivejs_maintenance";
} else if (sectionName === "webpack") {
appId = "BE4LKLLAJZ";
apiKey = "c233f26a1e0b4b0c54edbb2f06d85864";
indexName = "survivejs_webpack";
} else {
return null;
}
return (
<Algolia
appId={appId}
apiKey={apiKey}
indexName={indexName}
inputSelector="#search"
/>
);
};
const Algolia = ({
appId,
apiKey,
indexName,
inputSelector,
}) => (
<div>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"
/>
<script
type="text/javascript"
dangerouslySetInnerHTML={{
__html: `
docsearch({
appId: '${appId}',
apiKey: '${apiKey}',
indexName: '${indexName}',
inputSelector: '${inputSelector}',
debug: false
});
`,
}}
/>
</div>
);
export default Search;