模板允许您在单个集合或对象中定义多个结构化变体。当您需要在同一父级下具有不同的数据结构时,它们是理想的选择。
例如,在一个“页面”集合中,可能需要一个营销页面模板和一个内容页面模板,两个都在“页面”集合下。
模板的名称。
一个包含字段的数组。
在编辑器中显示的模板名称。
All properties marked as REQUIRED must be specified for the field to work properly.
export default defineConfig({//...schema: {collections: [{name: 'page',label: '网站页面',path: 'content/pages',format: 'mdx',templates: [{name: 'content',label: '内容页面',fields: [// ... 内容页面字段],},{name: 'marketing',label: '营销页面',inline: true,fields: [//... 营销页面字段],},],},],},})
Tina 使用与模板匹配的文件夹名称来正确组织文件,例如:
/content/pages/marketing/home.md/content/pages/content/about.md