@@ -16,26 +16,21 @@ module.exports = (options, ctx) => {
16
16
17
17
const enhancers = [
18
18
{
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' ) }
22
21
} ,
23
22
{
24
23
when : ( { regularPath } ) => regularPath . startsWith ( '/category/' ) ,
25
24
frontmatter : { layout : getLayout ( 'Category' , 'Page' ) }
26
25
} ,
27
26
{
28
- when : ( { regularPath } ) => regularPath === categoryIndexPageUrl ,
29
- frontmatter : { layout : getLayout ( 'Categories ' , 'Page' ) }
27
+ when : ( { regularPath } ) => regularPath === tagIndexPageUrl ,
28
+ frontmatter : { layout : getLayout ( 'Tags ' , 'Page' ) }
30
29
} ,
31
30
{
32
31
when : ( { regularPath } ) => regularPath . startsWith ( '/tag/' ) ,
33
32
frontmatter : { layout : getLayout ( 'Tag' , 'Page' ) }
34
33
} ,
35
- {
36
- when : ( { regularPath } ) => regularPath === tagIndexPageUrl ,
37
- frontmatter : { layout : getLayout ( 'Tags' , 'Page' ) }
38
- } ,
39
34
{
40
35
when : ( { regularPath } ) => regularPath === '/' ,
41
36
frontmatter : { layout : getLayout ( 'Layout' ) }
@@ -48,7 +43,12 @@ module.exports = (options, ctx) => {
48
43
} ,
49
44
data : { type : 'post' }
50
45
} ,
51
- ...pageEnhancers
46
+ ...pageEnhancers ,
47
+ {
48
+ when : ( { regularPath } ) => isDirectChild ( regularPath ) ,
49
+ frontmatter : { layout : getLayout ( 'Page' , 'Layout' ) } ,
50
+ data : { type : 'page' }
51
+ }
52
52
]
53
53
54
54
return {
@@ -65,7 +65,9 @@ module.exports = (options, ctx) => {
65
65
} ) => {
66
66
if ( when ( pageCtx ) ) {
67
67
Object . keys ( frontmatter ) . forEach ( key => {
68
- rawFrontmatter [ key ] = rawFrontmatter [ key ] || frontmatter [ key ]
68
+ if ( ! rawFrontmatter [ key ] ) {
69
+ rawFrontmatter [ key ] = frontmatter [ key ]
70
+ }
69
71
} )
70
72
Object . assign ( pageCtx , data )
71
73
}
@@ -75,7 +77,7 @@ module.exports = (options, ctx) => {
75
77
/**
76
78
* Create tag page and category page.
77
79
*/
78
- ready ( ) {
80
+ async ready ( ) {
79
81
const { pages } = ctx
80
82
const tagMap = { }
81
83
const categoryMap = { }
@@ -140,7 +142,7 @@ module.exports = (options, ctx) => {
140
142
frontmatter : { title : `${ categoryName } | Category` }
141
143
} ) )
142
144
]
143
- extraPages . forEach ( page => ctx . addPage ( page ) )
145
+ await Promise . all ( extraPages . map ( page => ctx . addPage ( page ) ) )
144
146
} ,
145
147
146
148
/**
0 commit comments