#too slow
1 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
- Authentication Overview
- Page Metadata - Collection Metadata
- Select - defaultPopulate collection config property
Community-Help:
Hey @viscid birch a few questions for you:
Are you using relationship fields on your Pages collection?
Are you using defaultPopluate?
Are you using blockReferences?
import type { Block } from "payload";
import { link } from "@/fields/link";
export const Archive: Block = {
slug: "archive",
interfaceName: "ArchiveBlock",
fields: [
{
name: "type",
type: "select",
defaultValue: "normal",
label: "Төрөл",
options: [
{
label: "Энгийн",
value: "normal",
},
{
label: "Зурагтай",
value: "yes_picture",
},
{
label: "Зураггүй",
value: "no_picture",
},
{
label: "Слайд",
value: "slider",
},
],
},
{
name: "introContent",
type: "richText",
localized: true,
label: "Гарчиг",
},
link({
appearances: false,
required: false,
}),
{
name: "selectedDocs",
type: "relationship",
hasMany: true,
label: "Онцлох",
relationTo: ["posts"],
admin: {
condition: (_, { type } = {}) => ["yes_picture"].includes(type),
},
},
{
name: "categories",
type: "relationship",
hasMany: true,
label: "Ангилал",
relationTo: "categories",
},
{
name: "limit",
type: "number",
admin: {
step: 1,
},
defaultValue: 3,
label: "Тоо",
},
],
labels: {
plural: "Мэдээ",
singular: "Мэдээ",
},
};
all my blocks created like this example
you should use blockReferences—that would likely speed things up massively. Move all your block imports to your payload config and define them once there. Then you can reference them in your Pages config
// storage-adapter-import-placeholder
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { payloadCloudPlugin } from '@payloadcms/payload-cloud'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from 'path'
import { buildConfig, createClientConfig } from 'payload'
import { fileURLToPath } from 'url'
import sharp from 'sharp'
import { Users } from './collections/Users'
import { Media } from './collections/Media'
import { Pages } from './collections/Pages'
import { Posts } from './collections/Posts'
import { Content } from './blocks/Content'
import { Hero } from './blocks/Hero'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
admin: {
user: Users.slug,
importMap: {
baseDir: path.resolve(dirname),
},
},
blocks: [Content, Hero],
localization: {
defaultLocale: 'en',
locales: [
{
code: 'en',
label: 'English',
},
{
code: 'es',
label: 'Spanish',
},
],
},
collections: [Users, Media, Pages, Posts],
editor: lexicalEditor(),
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
db: mongooseAdapter({
url: process.env.DATABASE_URI || '',
}),
sharp,
plugins: [
payloadCloudPlugin(),
// storage-adapter-placeholder
],
})
import { CollectionConfig } from 'payload'
export const Pages: CollectionConfig = {
slug: 'pages',
admin: {
useAsTitle: 'title',
},
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'layout',
type: 'blocks',
blocks: [],
blockReferences: ['hero', 'content'],
},
{
name: 'clientConfig',
type: 'ui',
admin: {
components: {
Field: '/ClientConfig#ClientConfig',
},
},
},
],
}
i changed to use that blockReference. it is still slow. does it work in dev mode? or only works in prod?