@@ -15,170 +15,161 @@ import Avatar from "../components/avatar"
15
15
import PrevAndNext from "../components/prev-and-next"
16
16
import FooterLinks from "../components/shared/footer-links"
17
17
18
- class BlogPostTemplate extends React . Component {
19
- render ( ) {
20
- const {
21
- pageContext : { prev, next } ,
22
- data : { mdx : post } ,
23
- } = this . props
24
- const BioLine = ( { children } ) => (
25
- < p
26
- sx = { {
27
- color : `textMuted` ,
28
- fontFamily : `heading` ,
29
- lineHeight : `dense` ,
30
- m : 0 ,
31
- } }
32
- >
33
- { children }
34
- </ p >
35
- )
18
+ export default function BlogPostTemplate ( { pageContext, data } ) {
19
+ const { prev, next } = pageContext
20
+ const post = data . mdx
21
+ const BioLine = ( { children } ) => (
22
+ < p
23
+ sx = { {
24
+ color : `textMuted` ,
25
+ fontFamily : `heading` ,
26
+ lineHeight : `dense` ,
27
+ m : 0 ,
28
+ } }
29
+ >
30
+ { children }
31
+ </ p >
32
+ )
36
33
37
- return (
38
- < >
39
- < Container >
40
- {
41
- // TODO
42
- // - settle on `docSearch-content` as selector to identify
43
- // Algolia DocSearch content
44
- // - make use of components/docsearch-content in place of <main>
45
- //
46
- // `post` and `post-body` are only in use as selectors in the
47
- // docsearch config for gatsbyjs.org for individual blog posts:
48
- // https://github.com/algolia/docsearch-configs/blob/89706210b62e2f384e52ca1b104f92bc0e225fff/configs/gatsbyjs.json#L71-L76
49
- }
50
- < main id = { `reach-skip-nav` } className = "post docSearch-content" >
51
- < BlogPostMetadata post = { post } />
52
- < div sx = { { display : `flex` , flexDirection : `column` } } >
53
- < section
54
- sx = { {
55
- display : `flex` ,
56
- mb : 5 ,
57
- [ mediaQueries . md ] : {
58
- mt : 3 ,
59
- mb : 9 ,
60
- } ,
61
- } }
62
- >
63
- < div css = { { flex : `0 0 auto` } } >
64
- < Link
65
- to = { post . frontmatter . author . fields . slug }
66
- css = { { "&&" : { borderBottom : 0 } } }
34
+ return (
35
+ < >
36
+ < Container >
37
+ {
38
+ // TODO
39
+ // - settle on `docSearch-content` as selector to identify
40
+ // Algolia DocSearch content
41
+ // - make use of components/docsearch-content in place of <main>
42
+ //
43
+ // `post` and `post-body` are only in use as selectors in the
44
+ // docsearch config for gatsbyjs.org for individual blog posts:
45
+ // https://github.com/algolia/docsearch-configs/blob/89706210b62e2f384e52ca1b104f92bc0e225fff/configs/gatsbyjs.json#L71-L76
46
+ }
47
+ < main id = { `reach-skip-nav` } className = "post docSearch-content" >
48
+ < BlogPostMetadata post = { post } />
49
+ < div sx = { { display : `flex` , flexDirection : `column` } } >
50
+ < section
51
+ sx = { {
52
+ display : `flex` ,
53
+ mb : 5 ,
54
+ [ mediaQueries . md ] : {
55
+ mt : 3 ,
56
+ mb : 9 ,
57
+ } ,
58
+ } }
59
+ >
60
+ < div css = { { flex : `0 0 auto` } } >
61
+ < Link
62
+ to = { post . frontmatter . author . fields . slug }
63
+ css = { { "&&" : { borderBottom : 0 } } }
64
+ >
65
+ < Avatar
66
+ image = { post . frontmatter . author . avatar . childImageSharp . fixed }
67
+ alt = { post . frontmatter . author . id }
68
+ overrideCSS = { { mr : 5 } }
69
+ />
70
+ </ Link >
71
+ </ div >
72
+ < div css = { { flex : `1 1 auto` } } >
73
+ < Link to = { post . frontmatter . author . fields . slug } >
74
+ < h4
75
+ sx = { {
76
+ fontSize : 3 ,
77
+ mb : 1 ,
78
+ color : `link.color` ,
79
+ } }
67
80
>
68
- < Avatar
69
- image = {
70
- post . frontmatter . author . avatar . childImageSharp . fixed
71
- }
72
- alt = { post . frontmatter . author . id }
73
- overrideCSS = { { mr : 5 } }
74
- />
75
- </ Link >
76
- </ div >
77
- < div css = { { flex : `1 1 auto` } } >
78
- < Link to = { post . frontmatter . author . fields . slug } >
79
- < h4
81
+ < span
80
82
sx = { {
81
- fontSize : 3 ,
82
- mb : 1 ,
83
- color : `link.color` ,
83
+ borderBottom : t => `1px solid ${ t . colors . link . border } ` ,
84
+ transition : t =>
85
+ `all ${ t . transition . speed . fast } ${ t . transition . curve . default } ` ,
86
+ "&:hover" : { borderColor : `link.hoverBorder` } ,
84
87
} }
85
88
>
86
- < span
87
- sx = { {
88
- borderBottom : t =>
89
- `1px solid ${ t . colors . link . border } ` ,
90
- transition : t =>
91
- `all ${ t . transition . speed . fast } ${ t . transition . curve . default } ` ,
92
- "&:hover" : { borderColor : `link.hoverBorder` } ,
93
- } }
94
- >
95
- { post . frontmatter . author . id }
96
- </ span >
97
- </ h4 >
98
- </ Link >
99
- < BioLine > { post . frontmatter . author . bio } </ BioLine >
100
- < BioLine >
101
- { post . timeToRead } min read · { post . frontmatter . date }
102
- { post . frontmatter . canonicalLink && (
103
- < span >
104
- { ` ` }
105
- (originally published at
89
+ { post . frontmatter . author . id }
90
+ </ span >
91
+ </ h4 >
92
+ </ Link >
93
+ < BioLine > { post . frontmatter . author . bio } </ BioLine >
94
+ < BioLine >
95
+ { post . timeToRead } min read · { post . frontmatter . date }
96
+ { post . frontmatter . canonicalLink && (
97
+ < span >
98
+ { ` ` }
99
+ (originally published at
100
+ { ` ` }
101
+ < a href = { post . frontmatter . canonicalLink } >
102
+ { post . fields . publishedAt }
103
+ </ a >
104
+ )
105
+ </ span >
106
+ ) }
107
+ </ BioLine >
108
+ </ div >
109
+ </ section >
110
+ < h1
111
+ sx = { {
112
+ marginTop : 0 ,
113
+ order : 0 ,
114
+ letterSpacing : `tight` ,
115
+ lineHeight : `dense` ,
116
+ fontSize : [ 6 , 7 , 8 , 9 , 11 ] ,
117
+ [ mediaQueries . lg ] : {
118
+ mb : 8 ,
119
+ } ,
120
+ } }
121
+ >
122
+ { post . frontmatter . title }
123
+ </ h1 >
124
+ { post . frontmatter . image &&
125
+ post . frontmatter . showImageInArticle !== false && (
126
+ < div
127
+ sx = { {
128
+ mt : 8 ,
129
+ mb : 12 ,
130
+ [ mediaQueries . lg ] : {
131
+ ml : `-8em` ,
132
+ } ,
133
+ } }
134
+ >
135
+ < Img fluid = { post . frontmatter . image . childImageSharp . fluid } />
136
+ { post . frontmatter . imageAuthor &&
137
+ post . frontmatter . imageAuthorLink && (
138
+ < em >
139
+ Image by
106
140
{ ` ` }
107
- < a href = { post . frontmatter . canonicalLink } >
108
- { post . fields . publishedAt }
141
+ < a href = { post . frontmatter . imageAuthorLink } >
142
+ { post . frontmatter . imageAuthor }
109
143
</ a >
110
- )
111
- </ span >
144
+ </ em >
112
145
) }
113
- </ BioLine >
114
146
</ div >
115
- </ section >
116
- < h1
117
- sx = { {
118
- marginTop : 0 ,
119
- order : 0 ,
120
- letterSpacing : `tight` ,
121
- lineHeight : `dense` ,
122
- fontSize : [ 6 , 7 , 8 , 9 , 11 ] ,
123
- [ mediaQueries . lg ] : {
124
- mb : 8 ,
125
- } ,
126
- } }
127
- >
128
- { post . frontmatter . title }
129
- </ h1 >
130
- { post . frontmatter . image &&
131
- post . frontmatter . showImageInArticle !== false && (
132
- < div
133
- sx = { {
134
- mt : 8 ,
135
- mb : 12 ,
136
- [ mediaQueries . lg ] : {
137
- ml : `-8em` ,
138
- } ,
139
- } }
140
- >
141
- < Img fluid = { post . frontmatter . image . childImageSharp . fluid } />
142
- { post . frontmatter . imageAuthor &&
143
- post . frontmatter . imageAuthorLink && (
144
- < em >
145
- Image by
146
- { ` ` }
147
- < a href = { post . frontmatter . imageAuthorLink } >
148
- { post . frontmatter . imageAuthor }
149
- </ a >
150
- </ em >
151
- ) }
152
- </ div >
153
- ) }
154
- </ div >
155
- < section className = "post-body" >
156
- < MDXRenderer > { post . body } </ MDXRenderer >
157
- </ section >
158
- < TagsSection tags = { post . frontmatter . tags } />
159
- < EmailCaptureForm />
160
- </ main >
147
+ ) }
148
+ </ div >
149
+ < section className = "post-body" >
150
+ < MDXRenderer > { post . body } </ MDXRenderer >
151
+ </ section >
152
+ < TagsSection tags = { post . frontmatter . tags } />
153
+ < EmailCaptureForm />
154
+ </ main >
155
+ </ Container >
156
+ < div
157
+ sx = { {
158
+ borderTop : t => `1px solid ${ t . colors . ui . border } ` ,
159
+ mt : 9 ,
160
+ [ mediaQueries . md ] : { pt : 5 } ,
161
+ [ mediaQueries . lg ] : { pt : 7 } ,
162
+ } }
163
+ >
164
+ < Container >
165
+ < PrevAndNext prev = { prev } next = { next } />
161
166
</ Container >
162
- < div
163
- sx = { {
164
- borderTop : t => `1px solid ${ t . colors . ui . border } ` ,
165
- mt : 9 ,
166
- [ mediaQueries . md ] : { pt : 5 } ,
167
- [ mediaQueries . lg ] : { pt : 7 } ,
168
- } }
169
- >
170
- < Container >
171
- < PrevAndNext prev = { prev } next = { next } />
172
- </ Container >
173
- < FooterLinks />
174
- </ div >
175
- </ >
176
- )
177
- }
167
+ < FooterLinks />
168
+ </ div >
169
+ </ >
170
+ )
178
171
}
179
172
180
- export default BlogPostTemplate
181
-
182
173
export const pageQuery = graphql `
183
174
query($slug: String!) {
184
175
mdx(fields: { slug: { eq: $slug } }) {
0 commit comments