import { createContentField } from '@/lib/keystatic/fields/content'
import { fields } from '@keystatic/core'
import { createPublishingField } from './publishing'
import { createSeoField } from './seo'

export const createArticleFields = (imageSubfolder: string) => ({
  title: fields.slug({ name: { label: 'Title' } }),
  summary: fields.text({ label: 'Summary', multiline: true }),
  cover: fields.object({
    src: fields.image({
      label: 'Cover Image',
      directory: `public/images/covers/${imageSubfolder}`,
      publicPath: `/images/covers/${imageSubfolder}`,
    }),
    alt: fields.text({ label: 'Alt' }),
    caption: fields.text({ label: 'Caption', multiline: true }),
    showInHeader: fields.checkbox({
      label: 'Show in Header',
      defaultValue: false,
    }),
  }),
  publishing: createPublishingField(),
  seo: createSeoField(),
  content: createContentField(imageSubfolder),
})
