added categories to projects

This commit is contained in:
briannelson95
2025-10-11 10:05:23 -04:00
parent edaad9a3fc
commit 55859cf02a
3 changed files with 42 additions and 2 deletions

View File

@@ -49,7 +49,12 @@ export const Projects: CollectionConfig = {
{ {
label: 'Settings', label: 'Settings',
fields: [ fields: [
{
name: 'categories',
type: 'relationship',
hasMany: true,
relationTo: 'categories'
}
] ]
} }
] ]

View File

@@ -69,6 +69,7 @@ export interface Config {
collections: { collections: {
pages: Page; pages: Page;
projects: Project; projects: Project;
categories: Category;
users: User; users: User;
media: Media; media: Media;
'payload-locked-documents': PayloadLockedDocument; 'payload-locked-documents': PayloadLockedDocument;
@@ -79,6 +80,7 @@ export interface Config {
collectionsSelect: { collectionsSelect: {
pages: PagesSelect<false> | PagesSelect<true>; pages: PagesSelect<false> | PagesSelect<true>;
projects: ProjectsSelect<false> | ProjectsSelect<true>; projects: ProjectsSelect<false> | ProjectsSelect<true>;
categories: CategoriesSelect<false> | CategoriesSelect<true>;
users: UsersSelect<false> | UsersSelect<true>; users: UsersSelect<false> | UsersSelect<true>;
media: MediaSelect<false> | MediaSelect<true>; media: MediaSelect<false> | MediaSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>; 'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
@@ -172,6 +174,7 @@ export interface Project {
} | null; } | null;
link?: string | null; link?: string | null;
github?: string | null; github?: string | null;
categories?: (number | Category)[] | null;
/** /**
* When enabled, the slug will auto-generate from the title field on save and autosave. * When enabled, the slug will auto-generate from the title field on save and autosave.
*/ */
@@ -182,6 +185,21 @@ export interface Project {
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
} }
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "categories".
*/
export interface Category {
id: number;
title: string;
/**
* When enabled, the slug will auto-generate from the title field on save and autosave.
*/
generateSlug?: boolean | null;
slug: string;
updatedAt: string;
createdAt: string;
}
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users". * via the `definition` "users".
@@ -242,6 +260,10 @@ export interface PayloadLockedDocument {
relationTo: 'projects'; relationTo: 'projects';
value: number | Project; value: number | Project;
} | null) } | null)
| ({
relationTo: 'categories';
value: number | Category;
} | null)
| ({ | ({
relationTo: 'users'; relationTo: 'users';
value: number | User; value: number | User;
@@ -314,6 +336,7 @@ export interface ProjectsSelect<T extends boolean = true> {
richText?: T; richText?: T;
link?: T; link?: T;
github?: T; github?: T;
categories?: T;
generateSlug?: T; generateSlug?: T;
slug?: T; slug?: T;
featuredProject?: T; featuredProject?: T;
@@ -321,6 +344,17 @@ export interface ProjectsSelect<T extends boolean = true> {
updatedAt?: T; updatedAt?: T;
createdAt?: T; createdAt?: T;
} }
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "categories_select".
*/
export interface CategoriesSelect<T extends boolean = true> {
title?: T;
generateSlug?: T;
slug?: T;
updatedAt?: T;
createdAt?: T;
}
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users_select". * via the `definition` "users_select".

View File

@@ -11,6 +11,7 @@ import { Users } from './collections/Users'
import { Media } from './collections/Media' import { Media } from './collections/Media'
import { Page } from './collections/Page' import { Page } from './collections/Page'
import { Projects } from './collections/Projects' import { Projects } from './collections/Projects'
import { Categories } from './collections/Categories'
const filename = fileURLToPath(import.meta.url) const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename) const dirname = path.dirname(filename)
@@ -22,7 +23,7 @@ export default buildConfig({
baseDir: path.resolve(dirname), baseDir: path.resolve(dirname),
}, },
}, },
collections: [Page, Projects, Users, Media], collections: [Page, Projects, Categories, Users, Media],
editor: lexicalEditor({ editor: lexicalEditor({
features: ({ defaultFeatures, rootFeatures }) => [ features: ({ defaultFeatures, rootFeatures }) => [
...defaultFeatures, ...defaultFeatures,