Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@payloadcms'],
}
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
printWidth: 100,
parser: "typescript",
semi: false,
singleQuote: true,
trailingComma: "all",
arrowParens: "avoid",
};
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"payload": "^1.1.26"
"payload": "^1.8.2"
},
"devDependencies": {
"@types/express": "^4.17.9",
Expand Down
6 changes: 3 additions & 3 deletions demo/src/collections/Pages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// const payload = require('payload');
import { CollectionConfig } from 'payload/types';
import type { CollectionConfig } from 'payload/types'

export const Pages: CollectionConfig = {
slug: 'pages',
Expand All @@ -25,6 +25,6 @@ export const Pages: CollectionConfig = {
label: 'Slug',
type: 'text',
required: true,
}
},
],
};
}
4 changes: 2 additions & 2 deletions demo/src/collections/Users.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CollectionConfig } from 'payload/types';
import type { CollectionConfig } from 'payload/types'

export const Users: CollectionConfig = {
slug: 'users',
Expand All @@ -13,4 +13,4 @@ export const Users: CollectionConfig = {
// Email added by default
// Add more fields as needed
],
};
}
38 changes: 17 additions & 21 deletions demo/src/payload.config.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
import { buildConfig } from 'payload/config';
import path from 'path';
import path from 'path'
import { buildConfig } from 'payload/config'

// import nestedPages from '../../dist';
import nestedPages from '../../src';
import { Users } from './collections/Users';
import { Pages } from './collections/Pages';
import nestedPages from '../../src'
import { Pages } from './collections/Pages'
import { Users } from './collections/Users'

export default buildConfig({
serverURL: 'http://localhost:3000',
admin: {
user: Users.slug,
webpack: (config) => {
webpack: config => {
const newConfig = {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
react: path.join(__dirname, "../node_modules/react"),
"react-dom": path.join(__dirname, "../node_modules/react-dom"),
"payload": path.join(__dirname, "../node_modules/payload"),
react: path.join(__dirname, '../node_modules/react'),
'react-dom': path.join(__dirname, '../node_modules/react-dom'),
payload: path.join(__dirname, '../node_modules/payload'),
},
},
};
}

return newConfig;
return newConfig
},
},
collections: [
Users,
Pages
],
collections: [Users, Pages],
// localization: {
// locales: [
// 'en',
Expand All @@ -41,14 +39,12 @@ export default buildConfig({
// },
plugins: [
nestedPages({
collections: [
'pages'
],
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: {
outputFile: path.resolve(__dirname, 'payload-types.ts')
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
});
})
14 changes: 7 additions & 7 deletions demo/src/seed/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Payload } from 'payload';
import type { Payload } from 'payload'

export const seed = async (payload: Payload) => {
payload.logger.info('Seeding data...');
export const seed = async (payload: Payload): Promise<void> => {
payload.logger.info('Seeding data...')

await payload.create({
collection: 'users',
data: {
email: 'dev@payloadcms.com',
password: 'test',
}
});
},
})

const { id: parentID } = await payload.create({
collection: 'pages',
Expand All @@ -24,7 +24,7 @@ export const seed = async (payload: Payload) => {
data: {
title: 'Child page',
slug: 'child-page',
parent: parentID
parent: parentID,
},
})

Expand All @@ -33,7 +33,7 @@ export const seed = async (payload: Payload) => {
data: {
title: 'Grandchild page',
slug: 'grandchild-page',
parent: childID
parent: childID,
},
})

Expand Down
26 changes: 14 additions & 12 deletions demo/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import express from 'express';
import payload from 'payload';
import { seed } from './seed';
import dotenv from 'dotenv'
dotenv.config()

require('dotenv').config();
const app = express();
import express from 'express'
import payload from 'payload'

import { seed } from './seed'
const app = express()

// Redirect root to Admin panel
app.get('/', (_, res) => {
res.redirect('/admin');
});
res.redirect('/admin')
})

// Initialize Payload
const start = async () => {
await payload.initAsync({
const start = async (): Promise<void> => {
await payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
Expand All @@ -22,10 +24,10 @@ const start = async () => {
})

if (process.env.PAYLOAD_SEED === 'true') {
await seed(payload);
await seed(payload)
}

app.listen(3000);
app.listen(3000)
}

start();
start()
Loading