From 1d59698ebe4c3b27744f43d616507b19b5bbea5c Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Mon, 4 May 2026 22:27:03 +0200 Subject: [PATCH] =?UTF-8?q?feat(blog):=20add=20articles=20collection=20(si?= =?UTF-8?q?mplified=20=E2=80=94=20no=20cross-feature=20refs)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integrations/cms/collections/articles.ts | 72 +++++++++++++++++++ packages/blog/src/integrations/cms/index.ts | 1 + 2 files changed, 73 insertions(+) create mode 100644 packages/blog/src/integrations/cms/collections/articles.ts create mode 100644 packages/blog/src/integrations/cms/index.ts diff --git a/packages/blog/src/integrations/cms/collections/articles.ts b/packages/blog/src/integrations/cms/collections/articles.ts new file mode 100644 index 0000000..027c134 --- /dev/null +++ b/packages/blog/src/integrations/cms/collections/articles.ts @@ -0,0 +1,72 @@ +import type { CollectionConfig } from "payload"; +import { slugifyIfMissing } from "@repo/core-shared/payload"; + +export const articles: CollectionConfig = { + slug: "articles", + admin: { + useAsTitle: "title", + defaultColumns: ["title", "status", "author", "updatedAt"], + }, + hooks: { + beforeChange: [slugifyIfMissing], + }, + versions: { + drafts: true, + }, + fields: [ + { + name: "title", + type: "text", + required: true, + maxLength: 255, + }, + { + name: "slug", + type: "text", + unique: true, + admin: { + position: "sidebar", + description: "Auto-generated from title if left empty", + }, + }, + { + name: "content", + type: "richText", + }, + { + name: "status", + type: "select", + options: [ + { label: "Draft", value: "draft" }, + { label: "Published", value: "published" }, + ], + defaultValue: "draft", + required: true, + admin: { + position: "sidebar", + }, + }, + // TODO(plan-3): Restore as `relationship → users` once auth feature is migrated. + { + name: "author", + type: "text", + required: true, + admin: { + position: "sidebar", + description: + "Temporary text field; restored to users relationship in Plan 3.", + }, + }, + // TODO(plan-3): Restore `featuredImage: upload → media` once media feature is migrated. + { + name: "publishedAt", + type: "date", + admin: { + position: "sidebar", + date: { + pickerAppearance: "dayAndTime", + }, + }, + }, + ], +}; diff --git a/packages/blog/src/integrations/cms/index.ts b/packages/blog/src/integrations/cms/index.ts new file mode 100644 index 0000000..5db37d5 --- /dev/null +++ b/packages/blog/src/integrations/cms/index.ts @@ -0,0 +1 @@ +export { articles } from "./collections/articles";