@@ -27,31 +27,23 @@ export const IGNORED_ROUTES = [
27
27
* counterpart route. This is useful for providing routes with matching Layout Names
28
28
* but that do not have Markdown content and a matching file for the route
29
29
*
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
31
31
*/
32
- export const DYNAMIC_ROUTES = async ( ) => {
33
- const blogCategories = await 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
+ ] ) ;
55
47
56
48
/**
57
49
* This is the default Next.js Page Metadata for all pages
0 commit comments