@@ -182,10 +182,7 @@ export const setApiRouteLayoutContext = (
182182 ? groupProperties (
183183 legacyProperty . properties ,
184184 legacyProperty . propertyGroups ,
185- {
186- include : metadata . include_groups ,
187- exclude : metadata . exclude_groups ,
188- } ,
185+ groupOptions ,
189186 )
190187 : null
191188
@@ -199,24 +196,31 @@ export const setApiRouteLayoutContext = (
199196 hidePreamble : route . path !== resource . routePath ,
200197 events : eventsByRoutePath . get ( resource . routePath ) ?? [ ] ,
201198 resourceSamples : resource . resourceSamples
202- . filter ( ( { title } ) => {
203- if ( groupOptions . include != null ) {
204- return groupOptions . include . some ( ( x ) =>
205- title . toLowerCase ( ) . includes ( x . split ( '_' ) [ 0 ] ?. slice ( 0 , - 1 ) ?? '' ) ,
206- )
207- }
208- if ( groupOptions . exclude != null ) {
209- return ! groupOptions . exclude . some ( ( x ) =>
210- title . toLowerCase ( ) . includes ( x . split ( '_' ) [ 0 ] ?. slice ( 0 , - 1 ) ?? '' ) ,
211- )
212- }
213- return true
214- } )
199+ . filter ( resourceSampleFilter ( groupOptions ) )
215200 . map ( mapResourceSample ) ,
216201 } )
217202 }
218203}
219204
205+ export const resourceSampleFilter =
206+ ( groupOptions : {
207+ include : string [ ] | undefined
208+ exclude ?: string [ ] | undefined
209+ } ) =>
210+ ( { title } : ResourceSample ) : boolean => {
211+ if ( groupOptions . include != null ) {
212+ return groupOptions . include . some ( ( x ) =>
213+ title . toLowerCase ( ) . includes ( x . split ( '_' ) [ 0 ] ?. slice ( 0 , - 1 ) ?? '' ) ,
214+ )
215+ }
216+ if ( groupOptions . exclude != null ) {
217+ return ! groupOptions . exclude . some ( ( x ) =>
218+ title . toLowerCase ( ) . includes ( x . split ( '_' ) [ 0 ] ?. slice ( 0 , - 1 ) ?? '' ) ,
219+ )
220+ }
221+ return true
222+ }
223+
220224const groupVariants = (
221225 property : Property | null ,
222226 {
0 commit comments