File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ exports.modifyWebpackConfig = ({config, stage}) => {
28
28
exports . createPages = async ( { graphql, boundActionCreators} ) => {
29
29
const { createPage, createRedirect} = boundActionCreators ;
30
30
31
+ // Used to detect and prevent duplicate redirects
32
+ const redirectToSlugMap = { } ;
33
+
31
34
const blogTemplate = resolve ( './src/templates/blog.js' ) ;
32
35
const communityTemplate = resolve ( './src/templates/community.js' ) ;
33
36
const docsTemplate = resolve ( './src/templates/docs.js' ) ;
@@ -114,13 +117,22 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
114
117
redirect = [ redirect ] ;
115
118
}
116
119
117
- redirect . forEach ( fromPath =>
120
+ redirect . forEach ( fromPath => {
121
+ if ( redirectToSlugMap [ fromPath ] != null ) {
122
+ console . error ( `Duplicate redirect detected from "${ fromPath } " to:\n` +
123
+ `* ${ redirectToSlugMap [ fromPath ] } \n` +
124
+ `* ${ slug } \n`
125
+ ) ;
126
+ process . exit ( 1 ) ;
127
+ }
128
+
129
+ redirectToSlugMap [ fromPath ] = slug ;
118
130
createRedirect ( {
119
131
fromPath : `/${ fromPath } ` ,
120
132
redirectInBrowser : true ,
121
133
toPath : `/${ slug } ` ,
122
- } ) ,
123
- ) ;
134
+ } ) ;
135
+ } ) ;
124
136
}
125
137
}
126
138
} ) ;
You can’t perform that action at this time.
0 commit comments