2025-02-12 14:22:55 +07:00
|
|
|
import formatSlug from "@/utils/formatSlug";
|
|
|
|
import type { CollectionConfig } from "payload";
|
|
|
|
|
|
|
|
export const BlogCategories: CollectionConfig = {
|
|
|
|
slug: "blogCategories",
|
|
|
|
labels: { plural: "Categories", singular: "Category" },
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: "name",
|
|
|
|
type: "text",
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "slug",
|
|
|
|
type: "text",
|
|
|
|
admin: {
|
|
|
|
position: "sidebar",
|
|
|
|
},
|
|
|
|
hooks: {
|
2025-02-12 16:58:51 +07:00
|
|
|
beforeValidate: [formatSlug("name")],
|
2025-02-12 14:22:55 +07:00
|
|
|
},
|
|
|
|
},
|
2025-02-12 16:58:51 +07:00
|
|
|
{
|
|
|
|
name: "parent_category",
|
|
|
|
label: "Parent Category",
|
|
|
|
type: "relationship",
|
|
|
|
relationTo: "blogCategories",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "description",
|
|
|
|
type: "textarea",
|
|
|
|
},
|
2025-02-12 14:22:55 +07:00
|
|
|
],
|
|
|
|
admin: {
|
|
|
|
hideAPIURL: true,
|
|
|
|
group: "Blogs",
|
2025-02-12 16:58:51 +07:00
|
|
|
useAsTitle: "name",
|
2025-02-12 14:22:55 +07:00
|
|
|
},
|
|
|
|
};
|