Skip to content

Commit 37d3008

Browse files
committed
fix(preview): handle index file in prefix folder (i18n)
1 parent c482e8d commit 37d3008

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/runtime/internal/preview/collection.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { minimatch } from 'minimatch'
22
import type { CollectionInfo, ResolvedCollectionSource } from '@nuxt/content'
3-
import { joinURL } from 'ufo'
3+
import { joinURL, withoutLeadingSlash } from 'ufo'
44
import type { JsonSchema7ObjectType } from 'zod-to-json-schema'
55
import { getOrderedSchemaKeys } from '../schema'
66
import { parseSourceBase } from './utils'
@@ -39,8 +39,10 @@ export const getCollectionByRoutePath = (routePath: string, collections: Record<
3939
return
4040
}
4141

42-
if (routePath === '/') {
43-
return ['index.yml', 'index.yaml', 'index.md', 'index.json'].some((p) => {
42+
if (routePath === '/' || routePath === source.prefix) {
43+
const indexFiles = ['index.yml', 'index.yaml', 'index.md', 'index.json']
44+
const files = routePath === '/' ? indexFiles : indexFiles.map(file => withoutLeadingSlash(joinURL(source.prefix, file)))
45+
return files.some((p) => {
4446
return collection.source.find(source => minimatch(p, source.include))
4547
})
4648
}

0 commit comments

Comments
 (0)