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";