@@ -16,7 +16,7 @@ export const getCollectionByFilePath = (path: string, collections: Record<string
16
16
const pathWithoutRoot = withoutRoot ( path )
17
17
const paths = pathWithoutRoot === '/' ? [ 'index.yml' , 'index.yaml' , 'index.md' , 'index.json' ] : [ pathWithoutRoot ]
18
18
return paths . some ( ( p ) => {
19
- matchedSource = collection . source . find ( source => minimatch ( p , source . include ) )
19
+ matchedSource = collection . source . find ( source => minimatch ( p , source . include ) && ! source . exclude ?. some ( exclude => minimatch ( p , exclude ) ) )
20
20
return matchedSource
21
21
} )
22
22
} )
@@ -43,7 +43,7 @@ export const getCollectionByRoutePath = (routePath: string, collections: Record<
43
43
const indexFiles = [ 'index.yml' , 'index.yaml' , 'index.md' , 'index.json' ]
44
44
const files = routePath === '/' ? indexFiles : indexFiles . map ( file => withoutLeadingSlash ( joinURL ( source . prefix , file ) ) )
45
45
return files . some ( ( p ) => {
46
- return collection . source . find ( source => minimatch ( p , source . include ) )
46
+ return collection . source . find ( source => minimatch ( p , source . include ) && ! source . exclude ?. some ( exclude => minimatch ( p , exclude ) ) )
47
47
} )
48
48
}
49
49
@@ -53,10 +53,11 @@ export const getCollectionByRoutePath = (routePath: string, collections: Record<
53
53
54
54
const path = joinURL ( fixed , pathWithoutPrefix )
55
55
56
- // Remove extension from source.include
57
- const pattern = source . include . replace ( / \. [ ^ / . ] + $ / , '' )
56
+ const removeExtension = ( pattern : string ) => {
57
+ return pattern . replace ( / \. [ ^ / . ] + $ / , '' )
58
+ }
58
59
59
- return minimatch ( path , pattern )
60
+ return minimatch ( path , removeExtension ( source . include ) ) && ! source . exclude ?. some ( exclude => minimatch ( path , removeExtension ( exclude ) ) )
60
61
} )
61
62
62
63
return matchedSource
0 commit comments