@@ -16,26 +16,21 @@ module.exports = (options, ctx) => {
1616
1717 const enhancers = [
1818 {
19- when : ( { regularPath } ) => isDirectChild ( regularPath ) ,
20- frontmatter : { layout : getLayout ( 'Page' , 'Layout' ) } ,
21- data : { type : 'page' }
19+ when : ( { regularPath } ) => regularPath === categoryIndexPageUrl ,
20+ frontmatter : { layout : getLayout ( 'Categories' , 'Page' ) }
2221 } ,
2322 {
2423 when : ( { regularPath } ) => regularPath . startsWith ( '/category/' ) ,
2524 frontmatter : { layout : getLayout ( 'Category' , 'Page' ) }
2625 } ,
2726 {
28- when : ( { regularPath } ) => regularPath === categoryIndexPageUrl ,
29- frontmatter : { layout : getLayout ( 'Categories ' , 'Page' ) }
27+ when : ( { regularPath } ) => regularPath === tagIndexPageUrl ,
28+ frontmatter : { layout : getLayout ( 'Tags ' , 'Page' ) }
3029 } ,
3130 {
3231 when : ( { regularPath } ) => regularPath . startsWith ( '/tag/' ) ,
3332 frontmatter : { layout : getLayout ( 'Tag' , 'Page' ) }
3433 } ,
35- {
36- when : ( { regularPath } ) => regularPath === tagIndexPageUrl ,
37- frontmatter : { layout : getLayout ( 'Tags' , 'Page' ) }
38- } ,
3934 {
4035 when : ( { regularPath } ) => regularPath === '/' ,
4136 frontmatter : { layout : getLayout ( 'Layout' ) }
@@ -48,7 +43,12 @@ module.exports = (options, ctx) => {
4843 } ,
4944 data : { type : 'post' }
5045 } ,
51- ...pageEnhancers
46+ ...pageEnhancers ,
47+ {
48+ when : ( { regularPath } ) => isDirectChild ( regularPath ) ,
49+ frontmatter : { layout : getLayout ( 'Page' , 'Layout' ) } ,
50+ data : { type : 'page' }
51+ }
5252 ]
5353
5454 return {
@@ -65,8 +65,8 @@ module.exports = (options, ctx) => {
6565 } ) => {
6666 if ( when ( pageCtx ) ) {
6767 Object . keys ( frontmatter ) . forEach ( key => {
68- if ( ! frontmatter [ key ] ) {
69- rawFrontmatter [ key ] || frontmatter [ key ]
68+ if ( ! rawFrontmatter [ key ] ) {
69+ rawFrontmatter [ key ] = frontmatter [ key ]
7070 }
7171 } )
7272 Object . assign ( pageCtx , data )
@@ -77,7 +77,7 @@ module.exports = (options, ctx) => {
7777 /**
7878 * Create tag page and category page.
7979 */
80- ready ( ) {
80+ async ready ( ) {
8181 const { pages } = ctx
8282 const tagMap = { }
8383 const categoryMap = { }
@@ -142,7 +142,7 @@ module.exports = (options, ctx) => {
142142 frontmatter : { title : `${ categoryName } | Category` }
143143 } ) )
144144 ]
145- extraPages . forEach ( page => ctx . addPage ( page ) )
145+ await Promise . all ( extraPages . map ( page => ctx . addPage ( page ) ) )
146146 } ,
147147
148148 /**
0 commit comments