Skip to content

Commit 6ab768c

Browse files
committed
WIP algolia
1 parent 8d1fc65 commit 6ab768c

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

gatsby-browser.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
exports.onClientEntry = () => {
2+
(function () {
3+
const path = 'https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css';
4+
const link = document.createElement('link');
5+
link.setAttribute('rel', 'stylesheet');
6+
link.setAttribute('type', 'text/css');
7+
link.setAttribute('href', path);
8+
document.head.appendChild(link);
9+
}());
10+
};

src/components/Search/index.jsx

+6-14
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,12 @@ import './search.scss';
33

44
class Search extends React.Component {
55
componentDidMount() {
6-
/* eslint-disable */
7-
(function (w, d, t, u, n, s, e) {
8-
w.SwiftypeObject = n; w[n] = w[n] || function () {
9-
(w[n].q = w[n].q || []).push(arguments);
10-
};
11-
s = d.createElement(t);
12-
e = d.getElementsByTagName(t)[0];
13-
s.async = 1;
14-
s.src = u;
15-
e.parentNode.insertBefore(s, e);
16-
}(window, document, 'script', '//s.swiftypecdn.com/install/v2/st.js', '_st'));
17-
18-
_st('install', 'NC4TVEWaL6p6zBLuL7eo', '2.0.0');
19-
/* eslint-enable */
6+
window.docsearch({
7+
apiKey: '621c583d8098d07c471dbaf6c2178e56',
8+
indexName: 'sendgrid_hc',
9+
inputSelector: '.search-query',
10+
debug: true, // Set debug to true if you want to inspect the dropdown
11+
});
2012
}
2113

2214
render() {

src/components/Search/search.scss

+4
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@
1919
border: none;
2020
box-shadow: none;
2121
}
22+
23+
.search-docs .algolia-autocomplete {
24+
width: 100%;
25+
}

src/html.jsx

+14
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,25 @@ export default class HTML extends React.Component {
3131
<html lang="en">
3232
<head>
3333
<meta charSet="utf-8" />
34+
<meta foobar="utf-8" />
3435
<meta
3536
name="viewport"
3637
content="width=device-width, initial-scale=1.0"
3738
/>
39+
<link
40+
rel="preload"
41+
href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"
42+
as="script"
43+
/>
44+
<link
45+
rel="preload"
46+
href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css"
47+
as="style"
48+
/>
3849
<script src="//cdn.optimizely.com/js/72168671.js" />
50+
<script
51+
src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"
52+
/>
3953
{this.props.headComponents}
4054
{/* <link rel="shortcut icon" href={favicon} /> */}
4155
{css}

0 commit comments

Comments
 (0)