UNPKG

@becklyn/contentful-adapter

Version:

[![CI](https://github.com/Becklyn-Studios/contentful-adapter/actions/workflows/ci.yml/badge.svg)](https://github.com/Becklyn-Studios/contentful-adapter/actions/workflows/ci.yml)

110 lines (109 loc) 4.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getBlockProcessMigration = void 0; const block_1 = require("./block"); const rte_1 = require("../rte"); const translations = { en: { blockProcess: { name: "🧩 Block > Process", fields: { headline: "Headline", steps: "Steps", labeledLink: "Button", }, }, blockProcessStep: { name: "🧩 Block > Process > Step", fields: { name: "Internal Name", title: "Title", text: "Text", }, }, }, de: { blockProcess: { name: "🧩 Block > Prozess", fields: { headline: "Überschrift", steps: "Schritte", labeledLink: "Button", }, }, blockProcessStep: { name: "🧩 Block > Prozess > Schritt", fields: { name: "Interner Name", title: "Titel", text: "Text", }, }, }, }; const getBlockProcessMigration = (language) => { const t = translations[language]; return { component: "blockProcess", migrations: { 1: migration => { const t = translations[language]; const blockProcessStep = migration.createContentType("blockProcessStep", { name: t.blockProcessStep.name, }); blockProcessStep.createField("name", { type: "Symbol", name: t.blockProcessStep.fields.name, required: true, }); blockProcessStep.createField("title", { type: "Symbol", name: t.blockProcessStep.fields.title, required: true, }); blockProcessStep.createField("text", { type: "RichText", name: t.blockProcessStep.fields.text, validations: (0, rte_1.getRteValidation)(rte_1.RTE_TYPE_STYLED_FONT), }); blockProcessStep.displayField("name"); const blockProcess = migration.createContentType("blockProcess", { name: t.blockProcess.name, }); blockProcess.createField("headline", { type: "Symbol", name: t.blockProcess.fields.headline, }); blockProcess.createField("steps", { type: "Array", name: t.blockProcess.fields.steps, items: { type: "Link", linkType: "Entry", validations: [{ linkContentType: ["blockProcessStep"] }], }, required: true, validations: [{ size: { max: 5 } }], }); blockProcess.createField("labeledLink", { type: "Link", name: t.blockProcess.fields.labeledLink, linkType: "Entry", validations: [{ linkContentType: ["labeledLink"] }], }); (0, block_1.migrateBaseBlockFields)(blockProcess, language); }, 2: migration => { const blockProcess = migration.editContentType("blockProcess"); blockProcess.deleteField("headline"); blockProcess.createField("headline", { type: "RichText", name: t.blockProcess.fields.headline, validations: (0, rte_1.getRteValidation)(rte_1.RTE_TYPE_HEADLINE), }); blockProcess.moveField("headline").afterField("name"); }, }, }; }; exports.getBlockProcessMigration = getBlockProcessMigration;