File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ if (process.env.NODE_ENV === `production`) {
20
20
}
21
21
}
22
22
23
+ const JS_NPM_URLS = [
24
+ '//unpkg.com/docsearch.js@2.4.1/dist/cdn/docsearch.min.js' ,
25
+ ] ;
26
+
23
27
export default class HTML extends Component {
24
28
render ( ) {
25
29
let css ;
@@ -32,6 +36,8 @@ export default class HTML extends Component {
32
36
) ;
33
37
}
34
38
39
+ const js = JS_NPM_URLS . map ( url => < script key = { url } src = { url } /> ) ;
40
+
35
41
return (
36
42
< html lang = "en" >
37
43
< head >
@@ -43,6 +49,7 @@ export default class HTML extends Component {
43
49
/>
44
50
< link rel = "icon" href = "/favicon.ico" />
45
51
{ this . props . headComponents }
52
+ { js }
46
53
{ css }
47
54
</ head >
48
55
< body >
Original file line number Diff line number Diff line change @@ -30,15 +30,13 @@ import 'css/algolia.css';
30
30
31
31
class Template extends Component {
32
32
componentDidMount ( ) {
33
- loadScript ( algoliaURL ) . then ( ( ) => {
34
- // Initialize Algolia search.
35
- // TODO Is this expensive? Should it be deferred until a user is about to search?
36
- // eslint-disable-next-line no-undef
37
- docsearch ( {
38
- apiKey : '36221914cce388c46d0420343e0bb32e' ,
39
- indexName : 'react' ,
40
- inputSelector : '#algolia-doc-search' ,
41
- } ) ;
33
+ // Initialize Algolia search.
34
+ // TODO Is this expensive? Should it be deferred until a user is about to search?
35
+ // eslint-disable-next-line no-undef
36
+ docsearch ( {
37
+ apiKey : '36221914cce388c46d0420343e0bb32e' ,
38
+ indexName : 'react' ,
39
+ inputSelector : '#algolia-doc-search' ,
42
40
} ) ;
43
41
}
44
42
Original file line number Diff line number Diff line change 15
15
const urlRoot = 'https://reactjs.org' ;
16
16
const version = '16.0.0' ;
17
17
const babelURL = '//unpkg.com/babel-standalone@6.26.0/babel.min.js' ;
18
- const algoliaURL = '//unpkg.com/docsearch.js@2.4.1/dist/cdn/docsearch.min.js' ;
19
18
20
- export { urlRoot , version , babelURL , algoliaURL } ;
19
+ export { urlRoot , version , babelURL , } ;
You can’t perform that action at this time.
0 commit comments