文档

学习

v.Latest
Documentation
Tina内容模型

Tina schema定义了内容的结构

Tina采用“代码化内容建模”的方法。

  • schema是版本控制的
  • 你可以在本地或分支中测试schema的更改。
  • 你可以以有趣的方式扩展schema(自定义验证、自定义UI字段等)。

具体来说,TinaCMS配置文件中的schema属性决定了内容存储与编辑器之间的数据映射。

schema.collections数组中的每个项目代表一种不同的内容结构。

每个项目包含一个fields数组,用于控制TinaCMS编辑器中显示的内容。

// tina/config.{ts,js,tsx}
import { defineConfig } from 'tinacms'
export default defineConfig({
// ...
schema: {
collections: [
//⤵️ 每个项目代表一种不同的内容结构
{
label: '博客文章',
name: 'post',
path: 'content/posts',
fields: [ //⤵️ 每个项目是编辑器中的一个新字段
{
type: 'string',
label: '标题',
name: 'title',
},
{
type: 'string',
label: '文章正文',
name: 'body',
isBody: true,
},
],
},
{
...
}
],
},
})
上次编辑: March 27, 2025