@@ -177,6 +177,31 @@ function useMultiOriginPalettes() {
177
177
return palettes ;
178
178
}
179
179
180
+ /**
181
+ * Get deduped examples for single page stylebook.
182
+ * @param {Array } examples Array of examples.
183
+ * @return {Array } Deduped examples.
184
+ */
185
+ export function getExamplesForSinglePageUse ( examples ) {
186
+ const examplesForSinglePageUse = [ ] ;
187
+ const overviewCategoryExamples = getExamplesByCategory (
188
+ { slug : 'overview' } ,
189
+ examples
190
+ ) ;
191
+ examplesForSinglePageUse . push ( ...overviewCategoryExamples . examples ) ;
192
+ const otherExamples = examples . filter ( ( example ) => {
193
+ return (
194
+ example . category !== 'overview' &&
195
+ ! overviewCategoryExamples . examples . find (
196
+ ( overviewExample ) => overviewExample . name === example . name
197
+ )
198
+ ) ;
199
+ } ) ;
200
+ examplesForSinglePageUse . push ( ...otherExamples ) ;
201
+
202
+ return examplesForSinglePageUse ;
203
+ }
204
+
180
205
function StyleBook ( {
181
206
enableResizing = true ,
182
207
isSelected,
@@ -203,21 +228,7 @@ function StyleBook( {
203
228
[ examples ]
204
229
) ;
205
230
206
- const examplesForSinglePageUse = [ ] ;
207
- const overviewCategoryExamples = getExamplesByCategory (
208
- { slug : 'overview' } ,
209
- examples
210
- ) ;
211
- examplesForSinglePageUse . push ( ...overviewCategoryExamples . examples ) ;
212
- const otherExamples = examples . filter ( ( example ) => {
213
- return (
214
- example . category !== 'overview' &&
215
- ! overviewCategoryExamples . examples . find (
216
- ( overviewExample ) => overviewExample . name === example . name
217
- )
218
- ) ;
219
- } ) ;
220
- examplesForSinglePageUse . push ( ...otherExamples ) ;
231
+ const examplesForSinglePageUse = getExamplesForSinglePageUse ( examples ) ;
221
232
222
233
const { base : baseConfig } = useContext ( GlobalStylesContext ) ;
223
234
const goTo = getStyleBookNavigationFromPath ( path ) ;
0 commit comments