1
1
import React from "react" ;
2
2
// import PropTypes from "prop-types";
3
- import { graphql } from "gatsby" ;
3
+ import { graphql , StaticQuery } from "gatsby" ;
4
4
import Markdown from "react-markdown/with-html" ;
5
5
6
6
import Layout from "../../components/4_layouts/layout" ;
@@ -27,69 +27,76 @@ const HeadingRenderer = props => {
27
27
return < Heading { ...props } /> ;
28
28
} ;
29
29
30
- window . addEventListener ( "scroll" , ( ) => {
31
- const top = window . scrollY ;
32
- const scrollButton = document . getElementById ( "back-to-top" ) ;
33
- if ( top >= 50 ) {
34
- scrollButton . classList . add ( "is-visible" ) ;
35
- } else {
36
- scrollButton . classList . remove ( "is-visible" ) ;
30
+ class APIDocs extends React . Component {
31
+ componentDidMount ( ) {
32
+ window . addEventListener ( "scroll" , ( ) => {
33
+ const top = window . scrollY ;
34
+ const scrollButton = document . getElementById ( "back-to-top" ) ;
35
+ if ( top >= 50 ) {
36
+ scrollButton . classList . add ( "is-visible" ) ;
37
+ } else {
38
+ scrollButton . classList . remove ( "is-visible" ) ;
39
+ }
40
+ } ) ;
37
41
}
38
- } ) ;
39
42
40
- const APIDocs = ( { data } ) => {
41
- const n = data . allDataJson . edges [ 0 ] . node ;
43
+ render ( ) {
44
+ const n = this . props . data . allDataJson . edges [ 0 ] . node ;
42
45
43
- return (
44
- < Layout
45
- // title="API Documentation"
46
- // subtitle="Linode API Documentation"
47
- fullWidth
48
- >
49
- < SEO title = "API Documentation" description = "" />
50
- < div className = "flex flex-wrap" >
51
- < div className = "md:hidden search-header-wrapper" >
52
- < SearchHeader />
53
- </ div >
54
- < div className = "sidebar-container" >
55
- < Sidebar />
56
- </ div >
57
- < div className = "w-full px-4 api-content-wrapper" >
58
- < div className = "api-content mx-auto" >
59
- < Markdown
60
- source = { n . info . description }
61
- escapeHtml = { false }
62
- renderers = { { heading : HeadingRenderer } }
63
- className = "md:mt-8 api-body"
64
- />
46
+ return (
47
+ < Layout
48
+ // title="API Documentation"
49
+ // subtitle="Linode API Documentation"
50
+ fullWidth
51
+ >
52
+ < SEO title = "API Documentation" description = "" />
53
+ < div className = "flex flex-wrap" >
54
+ < div className = "md:hidden search-header-wrapper" >
55
+ < SearchHeader />
56
+ </ div >
57
+ < div className = "sidebar-container" >
58
+ < Sidebar />
59
+ </ div >
60
+ < div className = "w-full px-4 api-content-wrapper" >
61
+ < div className = "api-content mx-auto" >
62
+ < Markdown
63
+ source = { n . info . description }
64
+ escapeHtml = { false }
65
+ renderers = { { heading : HeadingRenderer } }
66
+ className = "md:mt-8 api-body"
67
+ />
68
+ </ div >
65
69
</ div >
66
70
</ div >
67
- </ div >
68
- < div
69
- className = "back-to-top md:hidden"
70
- onClick = { scrollToTop }
71
- id = "back-to-top"
72
- >
73
- < span className = "back-to-top__caret" >
74
- < Caret / >
75
- </ span >
76
- </ div >
77
- </ Layout >
78
- ) ;
79
- } ;
71
+ < button
72
+ className = "back-to-top md:hidden"
73
+ onClick = { scrollToTop }
74
+ id = "back-to-top"
75
+ >
76
+ < span className = "back-to-top__caret" >
77
+ < Caret / >
78
+ </ span >
79
+ </ button >
80
+ </ Layout >
81
+ ) ;
82
+ }
83
+ }
80
84
81
- export const query = graphql `
82
- query apiV4 {
83
- allDataJson {
84
- edges {
85
- node {
86
- info {
87
- description
85
+ export default props => (
86
+ < StaticQuery
87
+ query = { graphql `
88
+ query {
89
+ allDataJson {
90
+ edges {
91
+ node {
92
+ info {
93
+ description
94
+ }
95
+ }
88
96
}
89
97
}
90
98
}
91
- }
92
- }
93
- ` ;
94
-
95
- export default APIDocs ;
99
+ ` }
100
+ render = { data => < APIDocs data = { data } { ...props } /> }
101
+ />
102
+ ) ;
0 commit comments