Loving Tina? us on GitHub0.0k

文档

学习

v.Latest
Documentation
文件属于多个集合错误
目录

当一个文件位于多个集合中时,会发生此错误。这通常是由于集合中的路径重叠或匹配属性中的错误导致的。

常见的解决方法是更新或添加匹配属性以排除或包含某些文件。

使用排除的示例

// tina/schema.ts
export default defineConfig({
collections: [
{
label: '博客文章',
name: 'posts',
path: 'content/posts',
// ..
},
{
label: '精选文章',
name: 'featuredPosts',
path: 'content/posts/featured',
// ...
},
//..
],
// ...
})

上面的示例配置会导致重叠,因为博客文章集合将包含精选文章集合中的所有文件。可以通过更新博客文章集合上的match.exclude属性来排除精选文章集合中的所有文件,从而解决此问题。

// tina/schema.ts
export default defineConfig({
collections: [
{
label: '博客文章',
name: 'posts',
path: 'content/posts',
match: {
exclude: 'featured/**/**',
},
// ..
},
{
label: '精选文章',
name: 'featuredPosts',
path: 'content/posts/featured',
// ...
},
//..
],
// ...
})

使用包含的示例

包含的一个示例可能是如果您只想包含具有特定名称的文件。例如,如果您想包含content/posts目录中所有名称为index的文件。

// tina/schema.ts
export default defineConfig({
collections: [
{
label: '博客文章',
name: 'posts',
path: 'content/posts',
match: {
include: '**/**/index',
},
// ..
},
//..
],
// ...
})