File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const GET_CATEGORIES = `
19
19
name
20
20
categoryId
21
21
slug
22
- posts {
22
+ posts(first:100) {
23
23
nodes {
24
24
...PostPreviewFragment
25
25
}
@@ -35,6 +35,7 @@ const allCategories = []
35
35
module . exports = async ( { actions, graphql } ) => {
36
36
37
37
const { createPage } = actions
38
+
38
39
const fetchCategories = async variables =>
39
40
await graphql ( GET_CATEGORIES , variables ) . then ( ( { data } ) => {
40
41
const {
@@ -45,18 +46,23 @@ module.exports = async ({ actions, graphql }) => {
45
46
} ,
46
47
} ,
47
48
} = data
49
+
48
50
nodes . map ( category => {
49
51
allCategories . push ( category )
50
52
} )
53
+
51
54
if ( hasNextPage ) {
52
55
return fetchCategories ( { first : 100 , after : endCursor } )
53
56
}
57
+
54
58
return allCategories
55
59
} )
56
60
57
61
await fetchCategories ( { first : 100 , after : null } ) . then ( allCategories => {
58
62
allCategories . map ( category => {
63
+
59
64
console . log ( `create category: ${ category . slug } ` )
65
+
60
66
createPage ( {
61
67
path : `/category/${ category . slug } ` ,
62
68
component : categoryTemplate ,
You can’t perform that action at this time.
0 commit comments