当一个文件位于多个集合中时,会发生此错误。这通常是由于集合中的路径重叠或匹配属性中的错误导致的。
常见的解决方法是更新或添加匹配属性以排除或包含某些文件。
// tina/schema.tsexport default defineConfig({collections: [{label: '博客文章',name: 'posts',path: 'content/posts',// ..},{label: '精选文章',name: 'featuredPosts',path: 'content/posts/featured',// ...},//..],// ...})
上面的示例配置会导致重叠,因为博客文章集合将包含精选文章集合中的所有文件。可以通过更新博客文章集合上的match.exclude
属性来排除精选文章集合中的所有文件,从而解决此问题。
// tina/schema.tsexport default defineConfig({collections: [{label: '博客文章',name: 'posts',path: 'content/posts',match: {exclude: 'featured/**/**',},// ..},{label: '精选文章',name: 'featuredPosts',path: 'content/posts/featured',// ...},//..],// ...})
包含的一个示例可能是如果您只想包含具有特定名称的文件。例如,如果您想包含content/posts
目录中所有名称为index
的文件。
// tina/schema.tsexport default defineConfig({collections: [{label: '博客文章',name: 'posts',path: 'content/posts',match: {include: '**/**/index',},// ..},//..],// ...})