import { collection, fields } from '@keystatic/core';

export default collection({
  label: 'Tags',
  slugField: 'name',
  path: 'content/taxonomy/tags/*',
  format: { data: 'json' },
  schema: {
    name: fields.slug({ name: { label: 'Name' } }),
    icon: fields.conditional(
      fields.select({
        label: 'Icon Type',
        defaultValue: 'none',
        options: [
          {
            value: 'none',
            label: 'None',
          },
          {
            value: 'glyph',
            label: 'Glyph',
          },
          {
            value: 'img',
            label: 'Image',
          },
        ],
      }),
      {
        none: fields.empty(),
        glyph: fields.text({ label: 'Glyph' }),
        img: fields.image({
          label: 'icon',
          publicPath: '/images/icons',
          directory: 'public/images/icons',
        }),
      }
    ),
    description: fields.text({ label: 'Description', multiline: true }),
  },
});
