File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ const path = require ( 'path' ) ;
2
+
3
+ exports . createPages = ( { boundActionCreators, graphql } ) => {
4
+ const { createPage } = boundActionCreators ;
5
+
6
+ const blogPostTemplate = path . resolve ( `src/templates/blog-post.js` ) ;
7
+
8
+ return graphql ( `{
9
+ allMarkdownRemark(
10
+ sort: { order: DESC, fields: [frontmatter___date] }
11
+ limit: 1000
12
+ ) {
13
+ edges {
14
+ node {
15
+ excerpt(pruneLength: 250)
16
+ html
17
+ id
18
+ frontmatter {
19
+ path
20
+ date
21
+ title
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }` ) . then ( result => {
27
+ if ( result . errors ) {
28
+ return Promise . reject ( result . errors ) ;
29
+ }
30
+ result . data . allMarkdownRemark . edges . forEach ( ( { node } ) => {
31
+ createPage ( {
32
+ path : node . frontmatter . path ,
33
+ component : blogPostTemplate ,
34
+ context : { } // additional data can be passed via context
35
+ } ) ;
36
+ } ) ;
37
+ } ) ;
38
+ }
You can’t perform that action at this time.
0 commit comments