@@ -13,20 +13,27 @@ import "./index.css";
13
13
14
14
const SEARCH_DOCS = true ;
15
15
16
- let docsearch ;
17
- if ( typeof window !== "undefined" && SEARCH_DOCS ) {
18
- docsearch = require ( "docsearch.js/dist/cdn/docsearch.min" ) ;
19
- try {
20
- docsearch ( {
21
- apiKey : "4b6d0afa80197db35886555b5ef4721f" ,
22
- inputSelector : "#search-docs" ,
23
- indexName : "graphene_python" ,
24
- debug : false
25
- } ) ;
26
- } catch ( e ) { }
27
- } else {
28
- docsearch = false ;
29
- }
16
+ // let docsearch;
17
+ // if (typeof window !== "undefined" && SEARCH_DOCS) {
18
+ // docsearch = require("docsearch.js/dist/cdn/docsearch.min");
19
+ // try {
20
+ // docsearch({
21
+ // apiKey: "4b6d0afa80197db35886555b5ef4721f",
22
+ // inputSelector: "#search-docs",
23
+ // indexName: "graphene_python",
24
+ // transformData: function(suggestions) {
25
+ // return suggestions.map(function(suggestion) {
26
+ // suggestion.url.replace("http:", "https:");
27
+ // return suggestion;
28
+ // });
29
+ // },
30
+ // // "start_urls": ["https://www.example.com/docs"],
31
+ // debug: false
32
+ // });
33
+ // } catch (e) {}
34
+ // } else {
35
+ // docsearch = false;
36
+ // }
30
37
31
38
const HeaderLink = ( { to, children, docs, ...extra } ) => {
32
39
if ( docs ) {
@@ -45,14 +52,23 @@ const HeaderLink = ({ to, children, docs, ...extra }) => {
45
52
46
53
class Header extends React . Component {
47
54
componentDidMount ( ) {
48
- if ( SEARCH_DOCS && docsearch ) {
49
- docsearch ( {
50
- apiKey : "4b6d0afa80197db35886555b5ef4721f" ,
51
- inputSelector : "#search-docs" ,
52
- indexName : "graphene_python"
53
- // debug: true
54
- } ) ;
55
- }
55
+ try {
56
+ if ( SEARCH_DOCS && typeof window !== "undefined" ) {
57
+ let docsearch = require ( "docsearch.js/dist/cdn/docsearch.min" ) ;
58
+ docsearch ( {
59
+ apiKey : "4b6d0afa80197db35886555b5ef4721f" ,
60
+ inputSelector : "#search-docs" ,
61
+ indexName : "graphene_python" ,
62
+ transformData : function ( suggestions ) {
63
+ return suggestions . map ( function ( suggestion ) {
64
+ suggestion . url = suggestion . url . replace ( "http:" , "https:" ) ;
65
+ return suggestion ;
66
+ } ) ;
67
+ }
68
+ // debug: true
69
+ } ) ;
70
+ }
71
+ } catch ( e ) { }
56
72
}
57
73
render ( ) {
58
74
let { docs } = this . props ;
@@ -378,7 +394,25 @@ const TemplateWrapper = ({ children, ...otherProps }) => {
378
394
{ name : "description" , content : "Graphene framework for Python" } ,
379
395
{ name : "keywords" , content : "graphene, graphql, python, framework" }
380
396
] }
381
- />
397
+ >
398
+ < script src = "https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" />
399
+ < script
400
+ dangerouslySetInnerHTML = { {
401
+ __html : `
402
+ docsearch({
403
+ apiKey: "4b6d0afa80197db35886555b5ef4721f",
404
+ inputSelector: "#search-docs",
405
+ indexName: "graphene_python",
406
+ transformData: function(suggestions) {
407
+ return suggestions.map(function(suggestion) {
408
+ suggestion.url = suggestion.url.replace("http:", "https:");
409
+ return suggestion;
410
+ });
411
+ }
412
+ });`
413
+ } }
414
+ />
415
+ </ Helmet >
382
416
< Header docs = { docs } />
383
417
< div > { children ( ) } </ div >
384
418
</ div >
0 commit comments