I'm having a few issues with my CMS.
Pages is blank and doesn't display a Create New page button with any fields.
My Pages.ts file has errors with the imports because I deleted those components. Should the server say successful if these imports are causing issues? I have yet to test if Pages works smoothly when the imports are corrected, for now I'm curious why I'm not getting any errors.
I've removed the squigglies and it still returns no errors, but Pages doesn't have a button to create Pages.
import type { CollectionConfig } from 'payload/types'
import { isAdmin } from '../access/isAdmin'
import { publishedOnly } from '../access/publishedOnly'
import { ContentGrid } from '../blocks/ContentGrid'
import { LinkGrid } from '../blocks/LinkGrid'
import { MediaBlock } from '../blocks/Media'
import { MediaContent } from '../blocks/MediaContent'
import { fullTitle } from '../fields/fullTitle'
import { slugField } from '../fields/slug'
import { formatPreviewURL } from '../utilities/formatPreviewURL'
import { regeneratePage } from '../utilities/regeneratePage'
import { Content } from '../blocks/Content'
export const Pages: CollectionConfig = {
slug: 'pages',
admin: {
useAsTitle: 'fullTitle',
preview: doc => formatPreviewURL('pages', doc),
defaultColumns: ['fullTitle', 'slug', 'createdAt', 'updatedAt'],
},
versions: {
drafts: true,
},
access: {
create: isAdmin,
read: publishedOnly,
readVersions: isAdmin,
update: isAdmin,
delete: isAdmin,
},
hooks: {
afterChange: [
({ req: { payload }, doc }) => {
regeneratePage({
payload,
collection: 'pages',
doc,
})
},
],
},
fields: [
{
name: 'title',
type: 'text',
required: true,
},
fullTitle,
{
type: 'tabs',
tabs: [
{
label: 'Content',
fields: [
{
name: 'layout',
type: 'blocks',
required: true,
blocks: [
Content,
ContentGrid,
LinkGrid,
MediaBlock,
MediaContent,
],
},
],
},
],
},
slugField(),
],
}
payloadconfig-
import { buildConfig } from 'payload/config';
import path from 'path';
import BlogCategories from './collections/BlogCategories';
import PortfolioCategories from './collections/PortfolioCategories';
import Posts from './collections/Posts';
import Tags from './collections/Tags';
import Users from './collections/Users';
import Media from './collections/Media';
import Items from './collections/Items';
import { Footer } from './globals/Footer';
import { MainMenu } from './globals/MainMenu';
import { Pages } from './collections/Pages';
export default buildConfig({
serverURL: 'http://localhost:4000',
admin: {
user: Users.slug,
},
collections: [
BlogCategories,
PortfolioCategories,
Posts,
Tags,
Users,
Media,
Items,
Pages,
],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts')
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
globals: [Footer, MainMenu],
});
are you logged in as an admin?
the create button will not show if the user does not have create access
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.