11// Import External Dependencies
22import React from 'react' ;
33import Banner from 'react-banner' ;
4+ import DocSearch from 'docsearch.js' ;
45
56// Import Utilities/Images
67import GitHubIcon from '../../styles/icons/github.svg' ;
@@ -12,33 +13,10 @@ import Logo from '../Logo/Logo';
1213import Dropdown from '../Dropdown/Dropdown' ;
1314
1415// Load Styling
16+ import 'docsearch.js/dist/cdn/docsearch.css' ;
1517import './Navigation.scss' ;
1618import './Search.scss' ;
1719
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-
4220export default class Navigation extends React . Component {
4321 render ( ) {
4422 let { pathname, links, toggleSidebar } = this . props ;
@@ -78,4 +56,12 @@ export default class Navigation extends React.Component {
7856 onMenuClick = { toggleSidebar } />
7957 ) ;
8058 }
59+
60+ componentDidMount ( ) {
61+ DocSearch ( {
62+ apiKey : 'fac401d1a5f68bc41f01fb6261661490' ,
63+ indexName : 'webpack-js-org' ,
64+ inputSelector : '.navigation-search__input'
65+ } ) ;
66+ }
8167}
0 commit comments