chore(plugin-nested-docs): migrates demo to payload 2.x
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
MONGODB_URI=mongodb://localhost/payload-plugin-form-builder
|
||||
PAYLOAD_SECRET=kajsnfkjhabndsfgseaniluanbsrkdgbhyasfg
|
||||
2
packages/plugin-nested-docs/dev/.env.example
Normal file
2
packages/plugin-nested-docs/dev/.env.example
Normal file
@@ -0,0 +1,2 @@
|
||||
DATABASE_URI=mongodb://localhost/payload-plugin-form-builder
|
||||
PAYLOAD_SECRET=kajsnfkjhabndsfgseaniluanbsrkdgbhyasfg
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "dist/server.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "cross-env PAYLOAD_SEED=true PAYLOAD_DROP_DATABASE=true PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
|
||||
"dev": "cross-env PAYLOAD_PUBLIC_SEED=true PAYLOAD_DROP_DATABASE=true PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
|
||||
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
|
||||
"build:server": "tsc",
|
||||
"build": "yarn build:payload && yarn build:server",
|
||||
@@ -13,9 +13,12 @@
|
||||
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types"
|
||||
},
|
||||
"dependencies": {
|
||||
"@payloadcms/bundler-webpack": "latest",
|
||||
"@payloadcms/db-mongodb": "latest",
|
||||
"@payloadcms/richtext-slate": "latest",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"payload": "^1.8.2"
|
||||
"payload": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.9",
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from 'react'
|
||||
|
||||
const BeforeLogin: React.FC = () => {
|
||||
if (process.env.PAYLOAD_PUBLIC_SEED === 'true') {
|
||||
return (
|
||||
<p>
|
||||
{'Log in with the email '}
|
||||
<strong>demo@payloadcms.com</strong>
|
||||
{' and the password '}
|
||||
<strong>demo</strong>.
|
||||
</p>
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export default BeforeLogin
|
||||
@@ -5,12 +5,20 @@ import { buildConfig } from 'payload/config'
|
||||
import nestedPages from '../../src' // eslint-disable-line import/no-relative-packages
|
||||
import { Pages } from './collections/Pages'
|
||||
import { Users } from './collections/Users'
|
||||
import { slateEditor } from '@payloadcms/richtext-slate'
|
||||
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
||||
import { webpackBundler } from '@payloadcms/bundler-webpack'
|
||||
import BeforeLogin from './components/BeforeLogin'
|
||||
|
||||
export default buildConfig({
|
||||
serverURL: 'http://localhost:3000',
|
||||
admin: {
|
||||
user: Users.slug,
|
||||
webpack: config => {
|
||||
bundler: webpackBundler(),
|
||||
components: {
|
||||
beforeLogin: [BeforeLogin],
|
||||
},
|
||||
webpack: (config) => {
|
||||
const newConfig = {
|
||||
...config,
|
||||
resolve: {
|
||||
@@ -27,6 +35,10 @@ export default buildConfig({
|
||||
return newConfig
|
||||
},
|
||||
},
|
||||
editor: slateEditor({}),
|
||||
db: mongooseAdapter({
|
||||
url: process.env.DATABASE_URI,
|
||||
}),
|
||||
collections: [Users, Pages],
|
||||
localization: {
|
||||
locales: ['en', 'es', 'de'],
|
||||
@@ -37,7 +49,7 @@ export default buildConfig({
|
||||
nestedPages({
|
||||
collections: ['pages'],
|
||||
generateLabel: (_, doc) => doc.title as string,
|
||||
generateURL: docs => docs.reduce((url, doc) => `${url}/${doc.slug}`, ''),
|
||||
generateURL: (docs) => docs.reduce((url, doc) => `${url}/${doc.slug}`, ''),
|
||||
}),
|
||||
],
|
||||
typescript: {
|
||||
@@ -6,8 +6,8 @@ export const seed = async (payload: Payload): Promise<void> => {
|
||||
await payload.create({
|
||||
collection: 'users',
|
||||
data: {
|
||||
email: 'dev@payloadcms.com',
|
||||
password: 'test',
|
||||
email: 'demo@payloadcms.com',
|
||||
password: 'demo',
|
||||
},
|
||||
})
|
||||
|
||||
@@ -16,14 +16,13 @@ app.get('/', (_, res) => {
|
||||
const start = async (): Promise<void> => {
|
||||
await payload.init({
|
||||
secret: process.env.PAYLOAD_SECRET,
|
||||
mongoURL: process.env.MONGODB_URI,
|
||||
express: app,
|
||||
onInit: () => {
|
||||
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
||||
},
|
||||
})
|
||||
|
||||
if (process.env.PAYLOAD_SEED === 'true') {
|
||||
if (process.env.PAYLOAD_PUBLIC_SEED === 'true') {
|
||||
await seed(payload)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"strict": false,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "../",
|
||||
"jsx": "react",
|
||||
"jsx": "react"
|
||||
},
|
||||
"ts-node": {
|
||||
"transpileOnly": true,
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import type { Config } from 'payload/config'
|
||||
import type { Plugin } from 'payload/config'
|
||||
|
||||
import createBreadcrumbsField from './fields/breadcrumbs'
|
||||
import createParentField from './fields/parent'
|
||||
@@ -8,10 +8,10 @@ import type { PluginConfig } from './types'
|
||||
import populateBreadcrumbs from './utilities/populateBreadcrumbs'
|
||||
|
||||
const nestedDocs =
|
||||
(pluginConfig: PluginConfig) =>
|
||||
(config: Config): Config => ({
|
||||
(pluginConfig: PluginConfig): Plugin =>
|
||||
(config) => ({
|
||||
...config,
|
||||
collections: (config.collections || []).map(collection => {
|
||||
collections: (config.collections || []).map((collection) => {
|
||||
if (pluginConfig.collections.indexOf(collection.slug) > -1) {
|
||||
const fields = [...(collection?.fields || [])]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user