Given the following config:
const Tag = defineDocumentType(() => ({
name: 'Tag',
filePathPattern: 'tags/*.md',
bodyType: 'none',
fields: {
title: { type: 'string', required: true },
},
}))
const Doc = defineDocumentType(() => ({
name: 'Doc',
filePathPattern: '**/*.mdx',
bodyType: 'mdx',
fields: {
title: { type: 'string', required: true },
tags: { type: 'list', of: Tag },
},
}))
export default makeSource({
contentDirPath: 'content',
documentTypes: [Doc, Tag],
})
The tags field on Doc type is a list of references. It should validate when a value doesn't match a valid (relative) path to a file matching the correct type.
Today if I do this in my doc's frontmatter:
---
title: Hello World
tags:
- Hello
- World
---
I see a warning:
└── 2 documents contain field data which didn't match the structure defined in the document type definition
• "index.mdx" of type "Doc" has the following incompatible fields:
• tags: undefined
• "sub/b.mdx" of type "Doc" has the following incompatible fields:
• tags: undefined
But it still generates the document with the list like so:
{
"title": "Hello World",
"tags": [
"Hello",
"World"
]
}
Given the following config:
The
tagsfield onDoctype is a list of references. It should validate when a value doesn't match a valid (relative) path to a file matching the correct type.Today if I do this in my doc's frontmatter:
I see a warning:
But it still generates the document with the list like so:
{ "title": "Hello World", "tags": [ "Hello", "World" ] }