File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -138,18 +138,23 @@ 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
154
if ( currentCategory ) {
152
- categories . push ( currentCategory ) ;
155
+ if ( ! ( currentCategory . name in categoriesMap ) ) {
156
+ categoriesMap [ currentCategory . name ] = currentCategory
157
+ }
153
158
}
154
159
currentCategory = {
155
160
name : category ,
@@ -167,9 +172,11 @@ exports.createPages = async ({ graphql, actions }) => {
167
172
}
168
173
}
169
174
170
- categories . push ( currentCategory )
175
+ if ( ! ( currentCategory . name in categoriesMap ) ) {
176
+ categoriesMap [ currentCategory . name ] = currentCategory
177
+ }
171
178
172
- sideBardata [ folder ] = categories
179
+ sideBardata [ folder ] = Object . values ( categoriesMap ) ;
173
180
} )
174
181
)
175
182
You can’t perform that action at this time.
0 commit comments