chore: seeds demo
This commit is contained in:
BIN
packages/plugin-seo/.DS_Store
vendored
BIN
packages/plugin-seo/.DS_Store
vendored
Binary file not shown.
2
packages/plugin-seo/.gitignore
vendored
2
packages/plugin-seo/.gitignore
vendored
@@ -3,3 +3,5 @@ node_modules
|
||||
dist
|
||||
demo/uploads
|
||||
build
|
||||
.DS_Store
|
||||
package-lock.json
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "dist/server.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
|
||||
"dev": "cross-env PAYLOAD_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,9 @@
|
||||
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types"
|
||||
},
|
||||
"dependencies": {
|
||||
"payload": "^1.0.9",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1"
|
||||
"express": "^4.17.1",
|
||||
"payload": "^1.1.26"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.9",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { GlobalConfig } from 'payload/types';
|
||||
|
||||
const HomePage: GlobalConfig = {
|
||||
slug: 'homePage',
|
||||
const Settings: GlobalConfig = {
|
||||
slug: 'settings',
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
@@ -15,4 +15,4 @@ const HomePage: GlobalConfig = {
|
||||
],
|
||||
}
|
||||
|
||||
export default HomePage;
|
||||
export default Settings;
|
||||
@@ -5,7 +5,7 @@ import seo from '../../src';
|
||||
import Users from './collections/Users';
|
||||
import Pages from './collections/Pages';
|
||||
import Media from './collections/Media';
|
||||
import HomePage from './globals/HomePage';
|
||||
import HomePage from './globals/Settings';
|
||||
|
||||
export default buildConfig({
|
||||
serverURL: 'http://localhost:3000',
|
||||
@@ -51,7 +51,7 @@ export default buildConfig({
|
||||
'pages',
|
||||
],
|
||||
globals: [
|
||||
'homePage',
|
||||
'settings',
|
||||
],
|
||||
uploadsCollection: 'media',
|
||||
generateTitle: ({ doc }: any) => `Website.com — ${doc?.title?.value}`,
|
||||
|
||||
22
packages/plugin-seo/demo/src/seed/index.ts
Normal file
22
packages/plugin-seo/demo/src/seed/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Payload } from 'payload';
|
||||
|
||||
export const seed = async (payload: Payload) => {
|
||||
payload.logger.info('Seeding data...');
|
||||
|
||||
await payload.create({
|
||||
collection: 'users',
|
||||
data: {
|
||||
email: 'dev@payloadcms.com',
|
||||
password: 'test',
|
||||
}
|
||||
});
|
||||
|
||||
await payload.create({
|
||||
collection: 'pages',
|
||||
data: {
|
||||
title: 'Home Page',
|
||||
slug: 'home',
|
||||
excerpt: 'This is the home page'
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import express from 'express';
|
||||
import payload from 'payload';
|
||||
import { seed } from './seed';
|
||||
|
||||
require('dotenv').config();
|
||||
const app = express();
|
||||
@@ -10,15 +11,21 @@ app.get('/', (_, res) => {
|
||||
});
|
||||
|
||||
// Initialize Payload
|
||||
payload.init({
|
||||
secret: process.env.PAYLOAD_SECRET,
|
||||
mongoURL: process.env.MONGODB_URI,
|
||||
express: app,
|
||||
onInit: () => {
|
||||
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
|
||||
},
|
||||
});
|
||||
const start = async () => {
|
||||
await payload.initAsync({
|
||||
secret: process.env.PAYLOAD_SECRET,
|
||||
mongoURL: process.env.MONGODB_URI,
|
||||
express: app,
|
||||
onInit: () => {
|
||||
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
||||
},
|
||||
})
|
||||
|
||||
// Add your own express routes here
|
||||
if (process.env.PAYLOAD_SEED === 'true') {
|
||||
await seed(payload);
|
||||
}
|
||||
|
||||
app.listen(3000);
|
||||
app.listen(3000);
|
||||
}
|
||||
|
||||
start();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,8 +26,6 @@
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.8",
|
||||
"@types/react-dom": "^18.0.3",
|
||||
"payload": "^1.0.9",
|
||||
"react": "^18.0.0",
|
||||
"typescript": "^4.5.5"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user