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

import { createContentField } from '@/keystatic/fields/content';
import { createSEOField } from '@/keystatic/fields/seo';
import { createMetaField } from '@/keystatic/fields/meta';

export const createArticleField = (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,
    }),
  }),
  meta: createMetaField(),
  seo: createSEOField(),
  content: createContentField(imageSubfolder),
});
