File tree 1 file changed +14
-5
lines changed 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -138,17 +138,24 @@ exports.createPages = async ({ graphql, actions }) => {
138
138
throw new Error ( `First page not found in ${ folder } ` )
139
139
}
140
140
141
- let categories = [ ]
141
+ let categoriesMap = { }
142
142
let currentCategory = null
143
143
144
144
let page = firstPage
145
145
let i = 0
146
146
while ( page && i ++ < 1000 ) {
147
147
const { frontmatter } = page
148
- const { category : definedCategory , next : definedNextPageUrl } = frontmatter
148
+ const {
149
+ category : definedCategory ,
150
+ next : definedNextPageUrl ,
151
+ } = frontmatter
149
152
let category = definedCategory || folder
150
153
if ( ! currentCategory || category !== currentCategory . name ) {
151
- currentCategory && categories . push ( currentCategory )
154
+ if ( currentCategory ) {
155
+ if ( ! ( currentCategory . name in categoriesMap ) ) {
156
+ categoriesMap [ currentCategory . name ] = currentCategory
157
+ }
158
+ }
152
159
currentCategory = {
153
160
name : category ,
154
161
links : [ ] ,
@@ -165,9 +172,11 @@ exports.createPages = async ({ graphql, actions }) => {
165
172
}
166
173
}
167
174
168
- categories . push ( currentCategory )
175
+ if ( ! ( currentCategory . name in categoriesMap ) ) {
176
+ categoriesMap [ currentCategory . name ] = currentCategory
177
+ }
169
178
170
- sideBardata [ folder ] = categories
179
+ sideBardata [ folder ] = Object . values ( categoriesMap ) ;
171
180
} )
172
181
)
173
182
You can’t perform that action at this time.
0 commit comments