File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -11,17 +11,15 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
11
11
12
12
createTypes ( gql `
13
13
type BlogPost implements Node
14
- @dontInfer
15
- @childOf(types: ["File", "MarkdownRemark"])
14
+ @childOf(types: ["MarkdownRemark"])
16
15
{
17
16
postId: String!
18
17
title: String!
19
- excerpt: String!
20
- rawContent: String! # raw markdown content, better if it would be fully parsed & rendered at the build time
21
18
tags: [String!]!
22
19
date: Date! @dateformat(formatString: "YYYY-MM-DD")
23
20
authors: [String!]!
24
21
guestBio: String
22
+ remark: MarkdownRemark! @link # backlink to the parent
25
23
}
26
24
` ) ;
27
25
} ;
@@ -52,8 +50,6 @@ exports.onCreateNode = async ({
52
50
id : nodeId ,
53
51
postId : permalink . replace ( '/blog/' , '' ) . replace ( / \/ $ / , '' ) ,
54
52
title : node . frontmatter . title ,
55
- excerpt : node . excerpt ,
56
- rawContent : node . rawMarkdownBody ,
57
53
tags : node . frontmatter . tags ?? [ ] ,
58
54
date : node . frontmatter . date ,
59
55
authors : ( node . frontmatter . byline ?? '' )
@@ -65,6 +61,7 @@ exports.onCreateNode = async ({
65
61
66
62
createNode ( {
67
63
...blogPostContent ,
64
+ remark : node . id ,
68
65
parent : node . id ,
69
66
children : [ ] ,
70
67
internal : {
Original file line number Diff line number Diff line change @@ -5,11 +5,13 @@ import Marked from "../Marked"
5
5
export const fragments = graphql `
6
6
fragment BlogPost_post on BlogPost {
7
7
title
8
- rawContent
9
8
date
10
9
authors
11
10
tags
12
11
guestBio
12
+ remark {
13
+ rawMarkdownBody
14
+ }
13
15
}
14
16
` ;
15
17
@@ -41,7 +43,7 @@ const BlogPost: React.FC<Props> = ({
41
43
< p className = "guestBio" > { `This guest article contributed by ${ byline } , ${ post . guestBio } .` } </ p >
42
44
) }
43
45
44
- < Marked > { post . rawContent } </ Marked >
46
+ < Marked > { post . remark . rawMarkdownBody } </ Marked >
45
47
</ div >
46
48
)
47
49
}
Original file line number Diff line number Diff line change @@ -4,11 +4,13 @@ import { graphql, Link } from "gatsby"
4
4
export const fragments = graphql `
5
5
fragment BlogPostPreview_post on BlogPost {
6
6
title
7
- excerpt
8
7
date
9
8
authors
10
9
tags
11
10
postPath: gatsbyPath(filePath: "/blog/{BlogPost.postId}")
11
+ remark {
12
+ excerpt
13
+ }
12
14
}
13
15
` ;
14
16
@@ -36,7 +38,7 @@ const BlogPostPreview: React.FC<Props> = ({
36
38
) ) }
37
39
</ div >
38
40
39
- < p > { post . excerpt } </ p >
41
+ < p > { post . remark . excerpt } </ p >
40
42
</ div >
41
43
)
42
44
You can’t perform that action at this time.
0 commit comments