From 6bd428214f59dcc5b404c8a0efd5c4213ae90045 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Mon, 4 May 2026 20:36:30 +0200 Subject: [PATCH] feat(core-shared): add cta block --- .../core-shared/src/payload/blocks/cta.test.ts | 16 ++++++++++++++++ packages/core-shared/src/payload/blocks/cta.ts | 10 ++++++++++ 2 files changed, 26 insertions(+) create mode 100644 packages/core-shared/src/payload/blocks/cta.test.ts create mode 100644 packages/core-shared/src/payload/blocks/cta.ts diff --git a/packages/core-shared/src/payload/blocks/cta.test.ts b/packages/core-shared/src/payload/blocks/cta.test.ts new file mode 100644 index 0000000..5e0546b --- /dev/null +++ b/packages/core-shared/src/payload/blocks/cta.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from "vitest"; +import { cta } from "./cta"; + +describe("cta block", () => { + it("has slug 'cta'", () => { + expect(cta.slug).toBe("cta"); + }); + + it("requires title, buttonLabel, and href", () => { + const fieldNames = cta.fields.map((f) => ("name" in f ? f.name : null)); + expect(fieldNames).toEqual(["title", "buttonLabel", "href"]); + cta.fields.forEach((f) => { + if ("required" in f) expect(f.required).toBe(true); + }); + }); +}); diff --git a/packages/core-shared/src/payload/blocks/cta.ts b/packages/core-shared/src/payload/blocks/cta.ts new file mode 100644 index 0000000..13cc399 --- /dev/null +++ b/packages/core-shared/src/payload/blocks/cta.ts @@ -0,0 +1,10 @@ +import type { Block } from "payload"; + +export const cta: Block = { + slug: "cta", + fields: [ + { name: "title", type: "text", required: true }, + { name: "buttonLabel", type: "text", required: true }, + { name: "href", type: "text", required: true }, + ], +};