-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The host website loads fine for us, but the nuxt studio part does not appear at all. The Console shows:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'include')
at parseSourceBase (collection.js:80:37)
at generateFsPathFromId (collection.js:63:21)
at getCollectionInfo (collection.js:72:18)
at Object.getFileSystemPath (host.js:166:16)
I investigated a bit and I think the issue is happening as soon as a collection is making use of the source.prefix feature. This code here tries to infer the FS path of a particular collection item by popping the first element (collection name) off of the id and using that as the path.
This usually works fine, except when the prefix / is used, which will transform the ID in a way that does not match the file structure anymore.
Our content.config.ts file looks like this:
export default defineContentConfig({
collections: {
pages: defineCollection({
type: 'page',
source: {
include: 'pages/**/*.md',
prefix: '/',
},
schema: z.object({ ... }),
}),
pricing: defineCollection({
type: 'data',
source: {
include: 'pricing/pricing.json',
},
schema: z.object({ ... }),
}),
},
});
which produces collection items along these lines
{
id: 'pages/1.index.md'
}
{
id: 'pricing/pricing/pricing.json'
}
which are assumed to be paths
{
path: '1.index.md'
}
{
path: 'pricing/pricing.json'
}
respectively.
This is of course not the actual layout of the files on disk.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working