Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

684 B
Raw Blame
import { ContentFields } from 'contentful-management';

type FieldProcessor = (field: ContentFields, value: any) => any;

export const FieldProcessors: Record<string, FieldProcessor> = {
  Link: (field, value) => {
    return {
      sys: {
        type: 'Link',
        linkType: field.linkType,
        id: value,
      },
    };
  },
  Array: (field, value) => {
    if (field.items?.type === 'Symbol') {
      return value;
    }
    if (field.items?.type === 'Link') {
      return value.map((v: string) => ({
        sys: {
          type: 'Link',
          linkType: field.items?.linkType,
          id: v,
        },
      }));
    }
  },
  Basic: (field, value) => value,
};