import { fields } from '@keystatic/core';
import type { ContentComponent } from '@keystatic/core/content-components';

import { generalComponents } from '@/keystatic/components/general';

export const createContentField = (
  imageSubfolder: string,
  additionalComponents?: Record<string, ContentComponent>
) =>
  fields.markdoc({
    label: 'Content',
    options: {
      image: {
        directory: `public/images/content/${imageSubfolder}`,
        publicPath: `/images/content/${imageSubfolder}`,
      },
    },
    components: {
      ...generalComponents,
      ...additionalComponents,
    },
  });
