File tree Expand file tree Collapse file tree 2 files changed +28
-18
lines changed Expand file tree Collapse file tree 2 files changed +28
-18
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
21
21
tags: [String!]!
22
22
date: Date! @dateformat(formatString: "YYYY-MM-DD")
23
23
authors: [String!]!
24
+ guestBio: String
24
25
}
25
26
` ) ;
26
27
} ;
@@ -59,6 +60,7 @@ exports.onCreateNode = async ({
59
60
. split ( ',' )
60
61
. map ( name => name . trim ( ) )
61
62
. filter ( Boolean ) ,
63
+ guestBio : node . frontmatter . guestBio ?? null ,
62
64
} ;
63
65
64
66
createNode ( {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export const fragments = graphql`
9
9
date
10
10
authors
11
11
tags
12
+ guestBio
12
13
}
13
14
` ;
14
15
@@ -18,24 +19,31 @@ interface Props {
18
19
19
20
const BlogPost : React . FC < Props > = ( {
20
21
post,
21
- } ) => (
22
- < div className = "inner-content" >
23
- < h1 > { post . title } </ h1 >
24
-
25
- < p >
26
- { new Date ( post . date ) . toLocaleDateString ( ) } by { post . authors . join ( ', ' ) }
27
- </ p >
28
-
29
- < div className = "tag-wrapper" >
30
- { post . tags . map ( tag => (
31
- < span key = { tag } className = "tag" >
32
- < Link to = { `/tags/${ tag } /` } > { tag } </ Link >
33
- </ span >
34
- ) ) }
35
- </ div >
22
+ } ) => {
23
+ const byline = post . authors . join ( ', ' )
24
+ return (
25
+ < div className = "inner-content" >
26
+ < h1 > { post . title } </ h1 >
27
+
28
+ < p >
29
+ { new Date ( post . date ) . toLocaleDateString ( ) } by { byline }
30
+ </ p >
31
+
32
+ < div className = "tag-wrapper" >
33
+ { post . tags . map ( tag => (
34
+ < span key = { tag } className = "tag" >
35
+ < Link to = { `/tags/${ tag } /` } > { tag } </ Link >
36
+ </ span >
37
+ ) ) }
38
+ </ div >
36
39
37
- < Marked > { post . rawContent } </ Marked >
38
- </ div >
39
- )
40
+ { post . guestBio && (
41
+ < p className = "guestBio" > { `This guest article contributed by ${ byline } , ${ post . guestBio } .` } </ p >
42
+ ) }
43
+
44
+ < Marked > { post . rawContent } </ Marked >
45
+ </ div >
46
+ )
47
+ }
40
48
41
49
export default BlogPost
You can’t perform that action at this time.
0 commit comments