@@ -27,31 +27,23 @@ export const IGNORED_ROUTES = [
2727 * counterpart route. This is useful for providing routes with matching Layout Names
2828 * but that do not have Markdown content and a matching file for the route
2929 *
30- * @type {() => Promise< Map<string, import('./types').Layouts> > } A Map of pathname and Layout Name
30+ * @type {Map<string, import('./types').Layouts> } A Map of pathname and Layout Name
3131 */
32- export const DYNAMIC_ROUTES = async ( ) => {
33- const blogCategories = provideBlogCategories ( ) ;
34-
35- const pages = [ ] ;
36- for ( const c of blogCategories ) {
37- const categoryPages = ( await provideBlogPosts ( c ) ) . pagination . pages ;
38- pages . push ( [ c , categoryPages ] ) ;
39- }
40-
41- return new Map ( [
42- // Provides Routes for all Blog Categories
43- ...blogCategories . map ( c => [ `blog/${ c } ` , 'blog-category' ] ) ,
44- // Provides Routes for all Blog Categories w/ Pagination
45- ...pages
46- // creates a numeric array for each page and define a pathname for
47- // each page for a category (i.e. blog/all/page/1)
48- . map ( ( [ c , t ] ) => [ ...Array ( t ) . keys ( ) ] . map ( p => `blog/${ c } /page/${ p + 1 } ` ) )
49- // creates a tuple of each pathname and layout for the route
50- . map ( paths => paths . map ( path => [ path , 'blog-category' ] ) )
51- // flattens the array since we have a .map inside another .map
52- . flat ( ) ,
53- ] ) ;
54- } ;
32+ export const DYNAMIC_ROUTES = new Map ( [
33+ // Provides Routes for all Blog Categories
34+ ...provideBlogCategories ( ) . map ( c => [ `blog/${ c } ` , 'blog-category' ] ) ,
35+ // Provides Routes for all Blog Categories w/ Pagination
36+ ...provideBlogCategories ( )
37+ // retrieves the amount of pages for each blog category
38+ . map ( c => [ c , provideBlogPosts ( c ) . pagination . pages ] )
39+ // creates a numeric array for each page and define a pathname for
40+ // each page for a category (i.e. blog/all/page/1)
41+ . map ( ( [ c , t ] ) => [ ...Array ( t ) . keys ( ) ] . map ( p => `blog/${ c } /page/${ p + 1 } ` ) )
42+ // creates a tuple of each pathname and layout for the route
43+ . map ( paths => paths . map ( path => [ path , 'blog-category' ] ) )
44+ // flattens the array since we have a .map inside another .map
45+ . flat ( ) ,
46+ ] ) ;
5547
5648/**
5749 * This is the default Next.js Page Metadata for all pages
0 commit comments