@@ -60,6 +60,7 @@ exports.createPages = async ({ graphql, actions }) => {
6060
6161 // Load templates
6262 const indexTemplate = path . resolve ( `./src/templates/index.js` ) ;
63+ const blogsTemplate = path . resolve ( `./src/templates/blogs.js` ) ;
6364 const tagsTemplate = path . resolve ( `./src/templates/tag.js` ) ;
6465 const authorTemplate = path . resolve ( `./src/templates/author.js` ) ;
6566 const pageTemplate = path . resolve ( `./src/templates/page.js` ) ;
@@ -89,27 +90,27 @@ exports.createPages = async ({ graphql, actions }) => {
8990 } ) ;
9091
9192 // Create author pages
92- authors . forEach ( ( { node } ) => {
93- const totalPosts = node . postCount !== null ? node . postCount : 0 ;
94-
95- // This part here defines, that our author pages will use
96- // a `/author/:slug/` permalink.
97- const url = `/author/${ node . slug } ` ;
98-
99- const items = Array . from ( { length : totalPosts } ) ;
100-
101- // Create pagination
102- paginate ( {
103- createPage,
104- items : items ,
105- itemsPerPage : postsPerPage ,
106- component : authorTemplate ,
107- pathPrefix : ( { pageNumber } ) => ( pageNumber === 0 ? url : `${ url } /page` ) ,
108- context : {
109- slug : node . slug ,
110- } ,
111- } ) ;
112- } ) ;
93+ // authors.forEach(({ node }) => {
94+ // const totalPosts = node.postCount !== null ? node.postCount : 0;
95+
96+ // // This part here defines, that our author pages will use
97+ // // a `/author/:slug/` permalink.
98+ // const url = `/author/${node.slug}`;
99+
100+ // const items = Array.from({ length: totalPosts });
101+
102+ // // Create pagination
103+ // paginate({
104+ // createPage,
105+ // items: items,
106+ // itemsPerPage: postsPerPage,
107+ // component: authorTemplate,
108+ // pathPrefix: ({ pageNumber }) => (pageNumber === 0 ? url : `${url}/page`),
109+ // context: {
110+ // slug: node.slug,
111+ // },
112+ // });
113+ // });
113114
114115 // Create pages
115116 pages . forEach ( ( { node } ) => {
@@ -159,6 +160,20 @@ exports.createPages = async ({ graphql, actions }) => {
159160 }
160161 } ,
161162 } ) ;
163+
164+ paginate ( {
165+ createPage,
166+ items : posts ,
167+ itemsPerPage : postsPerPage ,
168+ component : blogsTemplate ,
169+ pathPrefix : ( { pageNumber } ) => {
170+ if ( pageNumber === 0 ) {
171+ return `/blogs` ;
172+ } else {
173+ return `/blogs/page` ;
174+ }
175+ } ,
176+ } ) ;
162177} ;
163178
164179exports . onCreateWebpackConfig = ( { stage, actions } ) => {
@@ -168,3 +183,4 @@ exports.onCreateWebpackConfig = ({ stage, actions }) => {
168183 } ,
169184 } ) ;
170185} ;
186+
0 commit comments