@@ -7,36 +7,29 @@ const validatePrefixEntry = prefix => {
7
7
}
8
8
}
9
9
10
- exports . onCreatePage = ( { page, store , actions } , { prefixes } ) => {
10
+ exports . onCreatePage = ( { page, actions } , { prefixes } ) => {
11
11
const { createPage } = actions
12
12
const re = { }
13
13
prefixes . forEach ( validatePrefixEntry )
14
14
15
- return new Promise ( resolve => {
16
- // Don't set matchPath again if it's already been set.
17
- if ( page . matchPath || page . path . match ( / d e v - 4 0 4 - p a g e / ) ) {
18
- return resolve ( )
19
- }
20
-
21
- prefixes . forEach ( prefix => {
22
- if ( ! re [ prefix ] ) {
23
- // Remove the * from the prefix and memoize
24
- const trimmedPrefix = prefix . replace ( / \* $ / , `` )
25
- re [ prefix ] = new RegExp ( `^${ trimmedPrefix } ` )
26
- }
27
-
28
- // Ensure that the path ends in a trailing slash, since it can be removed.
29
- const path = page . path . match ( / \/ $ / ) ? page . path : `${ page . path } /`
15
+ // Don't set matchPath again if it's already been set.
16
+ if ( page . matchPath || page . path . match ( / d e v - 4 0 4 - p a g e / ) ) {
17
+ return
18
+ }
30
19
31
- if ( path . match ( re [ prefix ] ) ) {
32
- page . matchPath = prefix . replace ( / \* $ / , `*` )
33
- createPage ( page )
34
- return true
35
- }
20
+ prefixes . forEach ( prefix => {
21
+ if ( ! re [ prefix ] ) {
22
+ // Remove the * from the prefix and memoize
23
+ const trimmedPrefix = prefix . replace ( / \* $ / , `` )
24
+ re [ prefix ] = new RegExp ( `^${ trimmedPrefix } ` )
25
+ }
36
26
37
- return false
38
- } )
27
+ // Ensure that the path ends in a trailing slash, since it can be removed.
28
+ const path = page . path . match ( / \/ $ / ) ? page . path : ` ${ page . path } /`
39
29
40
- return resolve ( )
30
+ if ( path . match ( re [ prefix ] ) ) {
31
+ page . matchPath = prefix . replace ( / \* $ / , `*` )
32
+ createPage ( page )
33
+ }
41
34
} )
42
35
}
0 commit comments