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',
|
label: 'Publication Date',
|
||||||
name: 'date',
|
name: 'date',
|
||||||
type: 'string',
|
type: 'text',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'genre',
|
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;
|
repositories: Repository;
|
||||||
copies: Copy;
|
copies: Copy;
|
||||||
genre: Genre;
|
genre: Genre;
|
||||||
|
pages: Page;
|
||||||
'payload-locked-documents': PayloadLockedDocument;
|
'payload-locked-documents': PayloadLockedDocument;
|
||||||
'payload-preferences': PayloadPreference;
|
'payload-preferences': PayloadPreference;
|
||||||
'payload-migrations': PayloadMigration;
|
'payload-migrations': PayloadMigration;
|
||||||
};
|
};
|
||||||
collectionsJoins: {};
|
collectionsJoins: {
|
||||||
|
authors: {
|
||||||
|
books: 'books';
|
||||||
|
};
|
||||||
|
};
|
||||||
collectionsSelect: {
|
collectionsSelect: {
|
||||||
users: UsersSelect<false> | UsersSelect<true>;
|
users: UsersSelect<false> | UsersSelect<true>;
|
||||||
media: MediaSelect<false> | MediaSelect<true>;
|
media: MediaSelect<false> | MediaSelect<true>;
|
||||||
@ -87,6 +92,7 @@ export interface Config {
|
|||||||
repositories: RepositoriesSelect<false> | RepositoriesSelect<true>;
|
repositories: RepositoriesSelect<false> | RepositoriesSelect<true>;
|
||||||
copies: CopiesSelect<false> | CopiesSelect<true>;
|
copies: CopiesSelect<false> | CopiesSelect<true>;
|
||||||
genre: GenreSelect<false> | GenreSelect<true>;
|
genre: GenreSelect<false> | GenreSelect<true>;
|
||||||
|
pages: PagesSelect<false> | PagesSelect<true>;
|
||||||
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
|
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
|
||||||
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
|
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
|
||||||
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
|
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
|
||||||
@ -94,8 +100,12 @@ export interface Config {
|
|||||||
db: {
|
db: {
|
||||||
defaultIDType: number;
|
defaultIDType: number;
|
||||||
};
|
};
|
||||||
globals: {};
|
globals: {
|
||||||
globalsSelect: {};
|
header: Header;
|
||||||
|
};
|
||||||
|
globalsSelect: {
|
||||||
|
header: HeaderSelect<false> | HeaderSelect<true>;
|
||||||
|
};
|
||||||
locale: null;
|
locale: null;
|
||||||
user: User & {
|
user: User & {
|
||||||
collection: 'users';
|
collection: 'users';
|
||||||
@ -172,6 +182,7 @@ export interface Book {
|
|||||||
pages?: number | null;
|
pages?: number | null;
|
||||||
lcc?: string | null;
|
lcc?: string | null;
|
||||||
publication?: string | null;
|
publication?: string | null;
|
||||||
|
date?: string | null;
|
||||||
genre?: (number | Genre)[] | null;
|
genre?: (number | Genre)[] | null;
|
||||||
summary?: string | null;
|
summary?: string | null;
|
||||||
description?: {
|
description?: {
|
||||||
@ -201,6 +212,11 @@ export interface Author {
|
|||||||
lf: string;
|
lf: string;
|
||||||
fl?: string | null;
|
fl?: string | null;
|
||||||
role?: ('Author' | 'Translator' | 'Editor') | null;
|
role?: ('Author' | 'Translator' | 'Editor') | null;
|
||||||
|
books?: {
|
||||||
|
docs?: (number | Book)[];
|
||||||
|
hasNextPage?: boolean;
|
||||||
|
totalDocs?: number;
|
||||||
|
};
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
@ -257,6 +273,28 @@ export interface Copy {
|
|||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: 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
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "payload-locked-documents".
|
* via the `definition` "payload-locked-documents".
|
||||||
@ -291,6 +329,10 @@ export interface PayloadLockedDocument {
|
|||||||
| ({
|
| ({
|
||||||
relationTo: 'genre';
|
relationTo: 'genre';
|
||||||
value: number | Genre;
|
value: number | Genre;
|
||||||
|
} | null)
|
||||||
|
| ({
|
||||||
|
relationTo: 'pages';
|
||||||
|
value: number | Page;
|
||||||
} | null);
|
} | null);
|
||||||
globalSlug?: string | null;
|
globalSlug?: string | null;
|
||||||
user: {
|
user: {
|
||||||
@ -394,6 +436,7 @@ export interface AuthorsSelect<T extends boolean = true> {
|
|||||||
lf?: T;
|
lf?: T;
|
||||||
fl?: T;
|
fl?: T;
|
||||||
role?: T;
|
role?: T;
|
||||||
|
books?: T;
|
||||||
updatedAt?: T;
|
updatedAt?: T;
|
||||||
createdAt?: T;
|
createdAt?: T;
|
||||||
}
|
}
|
||||||
@ -430,6 +473,30 @@ export interface GenreSelect<T extends boolean = true> {
|
|||||||
updatedAt?: T;
|
updatedAt?: T;
|
||||||
createdAt?: 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
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "payload-locked-documents_select".
|
* via the `definition` "payload-locked-documents_select".
|
||||||
@ -462,6 +529,40 @@ export interface PayloadMigrationsSelect<T extends boolean = true> {
|
|||||||
updatedAt?: T;
|
updatedAt?: T;
|
||||||
createdAt?: 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
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "auth".
|
* via the `definition` "auth".
|
||||||
|
@ -13,6 +13,8 @@ import { Authors } from './collections/Authors/Authors'
|
|||||||
import { Repositories } from './collections/Repositories/Repositories'
|
import { Repositories } from './collections/Repositories/Repositories'
|
||||||
import { Copies } from './collections/Copies/Copies'
|
import { Copies } from './collections/Copies/Copies'
|
||||||
import { Genre } from './collections/Books/Genre'
|
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 filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename)
|
const dirname = path.dirname(filename)
|
||||||
@ -32,7 +34,8 @@ export default buildConfig({
|
|||||||
fileSize: 5000000, // in bytes
|
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(),
|
editor: lexicalEditor(),
|
||||||
secret: process.env.PAYLOAD_SECRET || '',
|
secret: process.env.PAYLOAD_SECRET || '',
|
||||||
typescript: {
|
typescript: {
|
||||||
@ -48,4 +51,11 @@ export default buildConfig({
|
|||||||
//payloadCloudPlugin(),
|
//payloadCloudPlugin(),
|
||||||
// storage-adapter-placeholder
|
// storage-adapter-placeholder
|
||||||
],
|
],
|
||||||
|
hooks: {
|
||||||
|
afterError: [
|
||||||
|
(error) => {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user