1
1
// Import External Dependencies
2
2
import React from 'react' ;
3
3
import Banner from 'react-banner' ;
4
+ import DocSearch from 'docsearch.js' ;
4
5
5
6
// Import Utilities/Images
6
7
import GitHubIcon from '../../styles/icons/github.svg' ;
@@ -12,33 +13,10 @@ import Logo from '../Logo/Logo';
12
13
import Dropdown from '../Dropdown/Dropdown' ;
13
14
14
15
// Load Styling
16
+ import 'docsearch.js/dist/cdn/docsearch.css' ;
15
17
import './Navigation.scss' ;
16
18
import './Search.scss' ;
17
19
18
- // TODO: Re-incorporate docsearch (see `react-banner` docs and `SearchResults` component/discussion)
19
- // componentDidMount() {
20
- // if (typeof window !== 'undefined') {
21
- // let docsearch = () => {};
22
-
23
- // // XXX: hack around docsearch
24
- // if (window.docsearch) {
25
- // docsearch = window.docsearch.default || window.docsearch;
26
- // }
27
-
28
- // docsearch({
29
- // apiKey: 'fac401d1a5f68bc41f01fb6261661490',
30
- // indexName: 'webpack-js-org',
31
- // inputSelector: '.navigation__search-input'
32
- // });
33
-
34
- // window.addEventListener('keyup', e => {
35
- // if (e.which === 9 && e.target.classList.contains('navigation__search-input')) {
36
- // this._openSearch();
37
- // }
38
- // });
39
- // }
40
- // }
41
-
42
20
export default class Navigation extends React . Component {
43
21
render ( ) {
44
22
let { pathname, links, toggleSidebar } = this . props ;
@@ -78,4 +56,12 @@ export default class Navigation extends React.Component {
78
56
onMenuClick = { toggleSidebar } />
79
57
) ;
80
58
}
59
+
60
+ componentDidMount ( ) {
61
+ DocSearch ( {
62
+ apiKey : 'fac401d1a5f68bc41f01fb6261661490' ,
63
+ indexName : 'webpack-js-org' ,
64
+ inputSelector : '.navigation-search__input'
65
+ } ) ;
66
+ }
81
67
}
0 commit comments