feat: updates to admin panel and added pages and heade nav global
This commit is contained in:
parent
13e716e91f
commit
9a4fa73ef6
42
src/blocks/Hero/Hero.ts
Normal file
42
src/blocks/Hero/Hero.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { Block } from 'payload'
|
||||
|
||||
export const Hero: Block = {
|
||||
slug: 'Hero',
|
||||
fields: [
|
||||
{
|
||||
name: 'heading',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
name: 'subheading',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
name: 'brief',
|
||||
type: 'textarea',
|
||||
},
|
||||
{
|
||||
name: 'minHeight',
|
||||
type: 'select',
|
||||
options: [
|
||||
{
|
||||
value: '100',
|
||||
label: 'Full'
|
||||
},
|
||||
{
|
||||
value: '80',
|
||||
label: '80%'
|
||||
},
|
||||
{
|
||||
value: '60',
|
||||
label: '60%'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'backgroundImage',
|
||||
type: 'relationship',
|
||||
relationTo: 'media',
|
||||
},
|
||||
]
|
||||
}
|
@ -46,5 +46,11 @@ export const Authors: CollectionConfig = {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'books',
|
||||
type: 'join',
|
||||
collection: 'books',
|
||||
on: 'authors',
|
||||
}
|
||||
],
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export const Books: CollectionConfig = {
|
||||
{
|
||||
label: 'Publication Date',
|
||||
name: 'date',
|
||||
type: 'string',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
name: 'genre',
|
||||
|
20
src/collections/Pages/Pages.ts
Normal file
20
src/collections/Pages/Pages.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { Hero } from "@/blocks/Hero/Hero";
|
||||
import { CollectionConfig } from "payload";
|
||||
|
||||
export const Pages: CollectionConfig = {
|
||||
slug: 'pages',
|
||||
admin: {
|
||||
useAsTitle: 'title',
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
name: 'layout',
|
||||
type: 'blocks',
|
||||
blocks: [Hero],
|
||||
},
|
||||
]
|
||||
}
|
31
src/globals/header/config.ts
Normal file
31
src/globals/header/config.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { GlobalConfig } from "payload";
|
||||
|
||||
|
||||
export const Header: GlobalConfig = {
|
||||
slug: 'header',
|
||||
label: 'Header Nav',
|
||||
fields: [
|
||||
{
|
||||
name: 'headerLinks',
|
||||
type: 'array',
|
||||
minRows: 1,
|
||||
maxRows: 5,
|
||||
fields: [
|
||||
{
|
||||
name: 'label',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
name: 'page',
|
||||
type: 'relationship',
|
||||
relationTo: 'pages'
|
||||
},
|
||||
{
|
||||
name: 'newTab',
|
||||
label: 'Open in new Tab?',
|
||||
type: 'checkbox',
|
||||
},
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
@ -74,11 +74,16 @@ export interface Config {
|
||||
repositories: Repository;
|
||||
copies: Copy;
|
||||
genre: Genre;
|
||||
pages: Page;
|
||||
'payload-locked-documents': PayloadLockedDocument;
|
||||
'payload-preferences': PayloadPreference;
|
||||
'payload-migrations': PayloadMigration;
|
||||
};
|
||||
collectionsJoins: {};
|
||||
collectionsJoins: {
|
||||
authors: {
|
||||
books: 'books';
|
||||
};
|
||||
};
|
||||
collectionsSelect: {
|
||||
users: UsersSelect<false> | UsersSelect<true>;
|
||||
media: MediaSelect<false> | MediaSelect<true>;
|
||||
@ -87,6 +92,7 @@ export interface Config {
|
||||
repositories: RepositoriesSelect<false> | RepositoriesSelect<true>;
|
||||
copies: CopiesSelect<false> | CopiesSelect<true>;
|
||||
genre: GenreSelect<false> | GenreSelect<true>;
|
||||
pages: PagesSelect<false> | PagesSelect<true>;
|
||||
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
|
||||
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
|
||||
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
|
||||
@ -94,8 +100,12 @@ export interface Config {
|
||||
db: {
|
||||
defaultIDType: number;
|
||||
};
|
||||
globals: {};
|
||||
globalsSelect: {};
|
||||
globals: {
|
||||
header: Header;
|
||||
};
|
||||
globalsSelect: {
|
||||
header: HeaderSelect<false> | HeaderSelect<true>;
|
||||
};
|
||||
locale: null;
|
||||
user: User & {
|
||||
collection: 'users';
|
||||
@ -172,6 +182,7 @@ export interface Book {
|
||||
pages?: number | null;
|
||||
lcc?: string | null;
|
||||
publication?: string | null;
|
||||
date?: string | null;
|
||||
genre?: (number | Genre)[] | null;
|
||||
summary?: string | null;
|
||||
description?: {
|
||||
@ -201,6 +212,11 @@ export interface Author {
|
||||
lf: string;
|
||||
fl?: string | null;
|
||||
role?: ('Author' | 'Translator' | 'Editor') | null;
|
||||
books?: {
|
||||
docs?: (number | Book)[];
|
||||
hasNextPage?: boolean;
|
||||
totalDocs?: number;
|
||||
};
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
@ -257,6 +273,28 @@ export interface Copy {
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "pages".
|
||||
*/
|
||||
export interface Page {
|
||||
id: number;
|
||||
title?: string | null;
|
||||
layout?:
|
||||
| {
|
||||
heading?: string | null;
|
||||
subheading?: string | null;
|
||||
brief?: string | null;
|
||||
minHeight?: ('100' | '80' | '60') | null;
|
||||
backgroundImage?: (number | null) | Media;
|
||||
id?: string | null;
|
||||
blockName?: string | null;
|
||||
blockType: 'Hero';
|
||||
}[]
|
||||
| null;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "payload-locked-documents".
|
||||
@ -291,6 +329,10 @@ export interface PayloadLockedDocument {
|
||||
| ({
|
||||
relationTo: 'genre';
|
||||
value: number | Genre;
|
||||
} | null)
|
||||
| ({
|
||||
relationTo: 'pages';
|
||||
value: number | Page;
|
||||
} | null);
|
||||
globalSlug?: string | null;
|
||||
user: {
|
||||
@ -394,6 +436,7 @@ export interface AuthorsSelect<T extends boolean = true> {
|
||||
lf?: T;
|
||||
fl?: T;
|
||||
role?: T;
|
||||
books?: T;
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
@ -430,6 +473,30 @@ export interface GenreSelect<T extends boolean = true> {
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "pages_select".
|
||||
*/
|
||||
export interface PagesSelect<T extends boolean = true> {
|
||||
title?: T;
|
||||
layout?:
|
||||
| T
|
||||
| {
|
||||
Hero?:
|
||||
| T
|
||||
| {
|
||||
heading?: T;
|
||||
subheading?: T;
|
||||
brief?: T;
|
||||
minHeight?: T;
|
||||
backgroundImage?: T;
|
||||
id?: T;
|
||||
blockName?: T;
|
||||
};
|
||||
};
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "payload-locked-documents_select".
|
||||
@ -462,6 +529,40 @@ export interface PayloadMigrationsSelect<T extends boolean = true> {
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "header".
|
||||
*/
|
||||
export interface Header {
|
||||
id: number;
|
||||
headerLinks?:
|
||||
| {
|
||||
label?: string | null;
|
||||
page?: (number | null) | Page;
|
||||
newTab?: boolean | null;
|
||||
id?: string | null;
|
||||
}[]
|
||||
| null;
|
||||
updatedAt?: string | null;
|
||||
createdAt?: string | null;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "header_select".
|
||||
*/
|
||||
export interface HeaderSelect<T extends boolean = true> {
|
||||
headerLinks?:
|
||||
| T
|
||||
| {
|
||||
label?: T;
|
||||
page?: T;
|
||||
newTab?: T;
|
||||
id?: T;
|
||||
};
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
globalType?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "auth".
|
||||
|
@ -13,6 +13,8 @@ import { Authors } from './collections/Authors/Authors'
|
||||
import { Repositories } from './collections/Repositories/Repositories'
|
||||
import { Copies } from './collections/Copies/Copies'
|
||||
import { Genre } from './collections/Books/Genre'
|
||||
import { Header } from './globals/header/config'
|
||||
import { Pages } from './collections/Pages/Pages'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
const dirname = path.dirname(filename)
|
||||
@ -32,7 +34,8 @@ export default buildConfig({
|
||||
fileSize: 5000000, // in bytes
|
||||
},
|
||||
},
|
||||
collections: [Users, Media, Books, Authors, Repositories, Copies, Genre],
|
||||
globals: [Header],
|
||||
collections: [Users, Media, Books, Authors, Repositories, Copies, Genre, Pages],
|
||||
editor: lexicalEditor(),
|
||||
secret: process.env.PAYLOAD_SECRET || '',
|
||||
typescript: {
|
||||
@ -48,4 +51,11 @@ export default buildConfig({
|
||||
//payloadCloudPlugin(),
|
||||
// storage-adapter-placeholder
|
||||
],
|
||||
hooks: {
|
||||
afterError: [
|
||||
(error) => {
|
||||
console.log(error)
|
||||
}
|
||||
],
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user