@@ -105,9 +105,12 @@ ${errors.map(error => error.message).join(`\n`)}`.trim(),
105
105
106
106
let derivePathErrors = 0
107
107
108
+ const knownPagePaths = new Set < string > ( )
109
+
108
110
// 3. Loop through each node and create the page, also save the path it creates to pass to the watcher
109
111
// the watcher will use this data to delete the pages if the query changes significantly.
110
- const paths = nodes . map ( ( node : Record < string , Record < string , unknown > > ) => {
112
+ const paths : Array < string > = [ ]
113
+ nodes . forEach ( ( node : Record < string , Record < string , unknown > > ) => {
111
114
// URL path for the component and node
112
115
const { derivedPath, errors } = derivePath (
113
116
filePath ,
@@ -116,6 +119,11 @@ ${errors.map(error => error.message).join(`\n`)}`.trim(),
116
119
slugifyOptions
117
120
)
118
121
const path = createPath ( derivedPath )
122
+ // We've already created a page with this path
123
+ if ( knownPagePaths . has ( path ) ) {
124
+ return
125
+ }
126
+ knownPagePaths . add ( path )
119
127
// Params is supplied to the FE component on props.params
120
128
const params = getCollectionRouteParams ( createPath ( filePath ) , path )
121
129
// nodeParams is fed to the graphql query for the component
@@ -135,7 +143,7 @@ ${errors.map(error => error.message).join(`\n`)}`.trim(),
135
143
136
144
derivePathErrors += errors
137
145
138
- return path
146
+ paths . push ( path )
139
147
} )
140
148
141
149
if ( derivePathErrors > 0 ) {
0 commit comments