import { defineSchema } from 'tinacms'

export const schema = defineSchema({
  collections: [
    {
      name: 'post',
      label: 'Posts',
      path: 'src/content/posts',
      format: 'mdx',
      fields: [
        {
          type: 'string',
          name: 'title',
          label: 'Title',
          required: true,
        },
        {
          type: 'string',
          name: 'description',
          label: 'Description',
        },
        {
          type: 'datetime',
          name: 'publishedAt',
          label: 'Published At',
        },
        {
          type: 'string',
          name: 'category',
          label: 'Category',
          options: ['news', 'blog', 'tutorial'],
        },
        {
          type: 'rich-text',
          name: 'body',
          label: 'Body',
          isBody: true,
        },
      ],
    },
    {
      name: 'page',
      label: 'Pages',
      path: 'src/content/pages',
      format: 'mdx',
      fields: [
        {
          type: 'string',
          name: 'title',
          label: 'Title',
          required: true,
        },
        {
          type: 'string',
          name: 'description',
          label: 'Description',
        },
        {
          type: 'rich-text',
          name: 'body',
          label: 'Body',
          isBody: true,
        },
      ],
    },
    {
      name: 'settings',
      label: 'Settings',
      path: 'src/content/settings',
      format: 'json',
      fields: [
        {
          type: 'string',
          name: 'siteName',
          label: 'Site Name',
        },
        {
          type: 'string',
          name: 'siteDescription',
          label: 'Site Description',
        },
        {
          type: 'string',
          name: 'language',
          label: 'Language',
          options: ['th', 'en', 'th-en'],
        },
      ],
    },
  ],
})
