Skip to content

Commit 8c06b12

Browse files
committed
update readme
1 parent 02008a1 commit 8c06b12

File tree

2 files changed

+23
-296
lines changed

2 files changed

+23
-296
lines changed

README.md

Lines changed: 20 additions & 287 deletions
Original file line numberDiff line numberDiff line change
@@ -1,303 +1,36 @@
1-
# Payload Website Template
1+
# Payload CMS
22

3-
This is the official [Payload Website Template](https://github.com/payloadcms/payload/blob/main/templates/website). Use it to power websites, blogs, or portfolios from small to enterprise. This repo includes a fully-working backend, enterprise-grade admin panel, and a beautifully designed, production-ready website.
3+
## Deploy
44

5-
This template is right for you if you are working on:
5+
> 不在服务端build
66
7-
- A personal or enterprise-grade website, blog, or portfolio
8-
- A content publishing platform with a fully featured publication workflow
9-
- Exploring the capabilities of Payload
7+
1. 本地build后,将.next提交
8+
2. server端拉取代码
9+
3. 取消`docker-compose.yml`注释: `command: sh -c "npm install -g pnpm && pnpm install && pnpm start"`
10+
4. 启动服务: `docker-compose up -d`
11+
5. 第一次启动时,`docker-compose exec payload sh`进入payload容器,`npm install -g pnpm`,然后执行`pnpm payload migrate:create``pnpm payload migrate`
1012

11-
Core features:
13+
## Command
1214

13-
- [Pre-configured Payload Config](#how-it-works)
14-
- [Authentication](#users-authentication)
15-
- [Access Control](#access-control)
16-
- [Layout Builder](#layout-builder)
17-
- [Draft Preview](#draft-preview)
18-
- [Live Preview](#live-preview)
19-
- [On-demand Revalidation](#on-demand-revalidation)
20-
- [SEO](#seo)
21-
- [Search](#search)
22-
- [Redirects](#redirects)
23-
- [Jobs and Scheduled Publishing](#jobs-and-scheduled-publish)
24-
- [Website](#website)
15+
### docker-compose
2516

26-
## Quick Start
17+
- 终止:`docker-compose down`
18+
- 重启:`docker-compose up -d`
2719

28-
To spin up this example locally, follow these steps:
20+
### git
2921

30-
### Clone
31-
32-
If you have not done so already, you need to have standalone copy of this repo on your machine. If you've already cloned this repo, skip to [Development](#development).
33-
34-
Use the `create-payload-app` CLI to clone this template directly to your machine:
22+
### 暂存某个文件
3523

3624
```bash
37-
pnpx create-payload-app my-project -t website
25+
git stash push -- docker-compose.yml
3826
```
3927

40-
### Development
41-
42-
1. First [clone the repo](#clone) if you have not done so already
43-
1. `cd my-project && cp .env.example .env` to copy the example environment variables
44-
1. `pnpm install && pnpm dev` to install dependencies and start the dev server
45-
1. open `http://localhost:3000` to open the app in your browser
46-
47-
That's it! Changes made in `./src` will be reflected in your app. Follow the on-screen instructions to login and create your first admin user. Then check out [Production](#production) once you're ready to build and serve your app, and [Deployment](#deployment) when you're ready to go live.
48-
49-
## How it works
50-
51-
The Payload config is tailored specifically to the needs of most websites. It is pre-configured in the following ways:
52-
53-
### Collections
54-
55-
See the [Collections](https://payloadcms.com/docs/configuration/collections) docs for details on how to extend this functionality.
56-
57-
- #### Users (Authentication)
58-
59-
Users are auth-enabled collections that have access to the admin panel and unpublished content. See [Access Control](#access-control) for more details.
60-
61-
For additional help, see the official [Auth Example](https://github.com/payloadcms/payload/tree/main/examples/auth) or the [Authentication](https://payloadcms.com/docs/authentication/overview#authentication-overview) docs.
62-
63-
- #### Posts
64-
65-
Posts are used to generate blog posts, news articles, or any other type of content that is published over time. All posts are layout builder enabled so you can generate unique layouts for each post using layout-building blocks, see [Layout Builder](#layout-builder) for more details. Posts are also draft-enabled so you can preview them before publishing them to your website, see [Draft Preview](#draft-preview) for more details.
66-
67-
- #### Pages
68-
69-
All pages are layout builder enabled so you can generate unique layouts for each page using layout-building blocks, see [Layout Builder](#layout-builder) for more details. Pages are also draft-enabled so you can preview them before publishing them to your website, see [Draft Preview](#draft-preview) for more details.
70-
71-
- #### Media
72-
73-
This is the uploads enabled collection used by pages, posts, and projects to contain media like images, videos, downloads, and other assets. It features pre-configured sizes, focal point and manual resizing to help you manage your pictures.
74-
75-
- #### Categories
76-
77-
A taxonomy used to group posts together. Categories can be nested inside of one another, for example "News > Technology". See the official [Payload Nested Docs Plugin](https://payloadcms.com/docs/plugins/nested-docs) for more details.
78-
79-
### Globals
80-
81-
See the [Globals](https://payloadcms.com/docs/configuration/globals) docs for details on how to extend this functionality.
82-
83-
- `Header`
84-
85-
The data required by the header on your front-end like nav links.
86-
87-
- `Footer`
88-
89-
Same as above but for the footer of your site.
90-
91-
## Access control
92-
93-
Basic access control is setup to limit access to various content based based on publishing status.
94-
95-
- `users`: Users can access the admin panel and create or edit content.
96-
- `posts`: Everyone can access published posts, but only users can create, update, or delete them.
97-
- `pages`: Everyone can access published pages, but only users can create, update, or delete them.
98-
99-
For more details on how to extend this functionality, see the [Payload Access Control](https://payloadcms.com/docs/access-control/overview#access-control) docs.
100-
101-
## Layout Builder
102-
103-
Create unique page layouts for any type of content using a powerful layout builder. This template comes pre-configured with the following layout building blocks:
104-
105-
- Hero
106-
- Content
107-
- Media
108-
- Call To Action
109-
- Archive
110-
111-
Each block is fully designed and built into the front-end website that comes with this template. See [Website](#website) for more details.
112-
113-
## Lexical editor
114-
115-
A deep editorial experience that allows complete freedom to focus just on writing content without breaking out of the flow with support for Payload blocks, media, links and other features provided out of the box. See [Lexical](https://payloadcms.com/docs/rich-text/overview) docs.
116-
117-
## Draft Preview
118-
119-
All posts and pages are draft-enabled so you can preview them before publishing them to your website. To do this, these collections use [Versions](https://payloadcms.com/docs/configuration/collections#versions) with `drafts` set to `true`. This means that when you create a new post, project, or page, it will be saved as a draft and will not be visible on your website until you publish it. This also means that you can preview your draft before publishing it to your website. To do this, we automatically format a custom URL which redirects to your front-end to securely fetch the draft version of your content.
120-
121-
Since the front-end of this template is statically generated, this also means that pages, posts, and projects will need to be regenerated as changes are made to published documents. To do this, we use an `afterChange` hook to regenerate the front-end when a document has changed and its `_status` is `published`.
122-
123-
For more details on how to extend this functionality, see the official [Draft Preview Example](https://github.com/payloadcms/payload/tree/examples/draft-preview).
124-
125-
## Live preview
126-
127-
In addition to draft previews you can also enable live preview to view your end resulting page as you're editing content with full support for SSR rendering. See [Live preview docs](https://payloadcms.com/docs/live-preview/overview) for more details.
128-
129-
## On-demand Revalidation
130-
131-
We've added hooks to collections and globals so that all of your pages, posts, footer, or header changes will automatically be updated in the frontend via on-demand revalidation supported by Nextjs.
132-
133-
> Note: if an image has been changed, for example it's been cropped, you will need to republish the page it's used on in order to be able to revalidate the Nextjs image cache.
134-
135-
## SEO
136-
137-
This template comes pre-configured with the official [Payload SEO Plugin](https://payloadcms.com/docs/plugins/seo) for complete SEO control from the admin panel. All SEO data is fully integrated into the front-end website that comes with this template. See [Website](#website) for more details.
138-
139-
## Search
140-
141-
This template also pre-configured with the official [Payload Search Plugin](https://payloadcms.com/docs/plugins/search) to showcase how SSR search features can easily be implemented into Next.js with Payload. See [Website](#website) for more details.
142-
143-
## Redirects
144-
145-
If you are migrating an existing site or moving content to a new URL, you can use the `redirects` collection to create a proper redirect from old URLs to new ones. This will ensure that proper request status codes are returned to search engines and that your users are not left with a broken link. This template comes pre-configured with the official [Payload Redirects Plugin](https://payloadcms.com/docs/plugins/redirects) for complete redirect control from the admin panel. All redirects are fully integrated into the front-end website that comes with this template. See [Website](#website) for more details.
146-
147-
## Jobs and Scheduled Publish
148-
149-
We have configured [Scheduled Publish](https://payloadcms.com/docs/versions/drafts#scheduled-publish) which uses the [jobs queue](https://payloadcms.com/docs/jobs-queue/jobs) in order to publish or unpublish your content on a scheduled time. The tasks are run on a cron schedule and can also be run as a separate instance if needed.
150-
151-
> Note: When deployed on Vercel, depending on the plan tier, you may be limited to daily cron only.
152-
153-
## Website
154-
155-
This template includes a beautifully designed, production-ready front-end built with the [Next.js App Router](https://nextjs.org), served right alongside your Payload app in a instance. This makes it so that you can deploy both your backend and website where you need it.
156-
157-
Core features:
158-
159-
- [Next.js App Router](https://nextjs.org)
160-
- [TypeScript](https://www.typescriptlang.org)
161-
- [React Hook Form](https://react-hook-form.com)
162-
- [Payload Admin Bar](https://github.com/payloadcms/payload/tree/main/packages/admin-bar)
163-
- [TailwindCSS styling](https://tailwindcss.com/)
164-
- [shadcn/ui components](https://ui.shadcn.com/)
165-
- User Accounts and Authentication
166-
- Fully featured blog
167-
- Publication workflow
168-
- Dark mode
169-
- Pre-made layout building blocks
170-
- SEO
171-
- Search
172-
- Redirects
173-
- Live preview
174-
175-
### Cache
176-
177-
Although Next.js includes a robust set of caching strategies out of the box, Payload Cloud proxies and caches all files through Cloudflare using the [Official Cloud Plugin](https://www.npmjs.com/package/@payloadcms/payload-cloud). This means that Next.js caching is not needed and is disabled by default. If you are hosting your app outside of Payload Cloud, you can easily reenable the Next.js caching mechanisms by removing the `no-store` directive from all fetch requests in `./src/app/_api` and then removing all instances of `export const dynamic = 'force-dynamic'` from pages files, such as `./src/app/(pages)/[slug]/page.tsx`. For more details, see the official [Next.js Caching Docs](https://nextjs.org/docs/app/building-your-application/caching).
178-
179-
## Development
180-
181-
To spin up this example locally, follow the [Quick Start](#quick-start). Then [Seed](#seed) the database with a few pages, posts, and projects.
182-
183-
### Working with Postgres
184-
185-
Postgres and other SQL-based databases follow a strict schema for managing your data. In comparison to our MongoDB adapter, this means that there's a few extra steps to working with Postgres.
186-
187-
Note that often times when making big schema changes you can run the risk of losing data if you're not manually migrating it.
188-
189-
#### Local development
190-
191-
Ideally we recommend running a local copy of your database so that schema updates are as fast as possible. By default the Postgres adapter has `push: true` for development environments. This will let you add, modify and remove fields and collections without needing to run any data migrations.
192-
193-
If your database is pointed to production you will want to set `push: false` otherwise you will risk losing data or having your migrations out of sync.
194-
195-
#### Migrations
196-
197-
[Migrations](https://payloadcms.com/docs/database/migrations) are essentially SQL code versions that keeps track of your schema. When deploy with Postgres you will need to make sure you create and then run your migrations.
198-
199-
Locally create a migration
200-
201-
```bash
202-
pnpm payload migrate:create
203-
```
204-
205-
This creates the migration files you will need to push alongside with your new configuration.
206-
207-
On the server after building and before running `pnpm start` you will want to run your migrations
208-
209-
```bash
210-
pnpm payload migrate
211-
```
212-
213-
This command will check for any migrations that have not yet been run and try to run them and it will keep a record of migrations that have been run in the database.
214-
215-
### Docker
216-
217-
Alternatively, you can use [Docker](https://www.docker.com) to spin up this template locally. To do so, follow these steps:
218-
219-
1. Follow [steps 1 and 2 from above](#development), the docker-compose file will automatically use the `.env` file in your project root
220-
1. Next run `docker-compose up`
221-
1. Follow [steps 4 and 5 from above](#development) to login and create your first admin user
222-
223-
That's it! The Docker instance will help you get up and running quickly while also standardizing the development environment across your teams.
224-
225-
### Seed
226-
227-
To seed the database with a few pages, posts, and projects you can click the 'seed database' link from the admin panel.
228-
229-
The seed script will also create a demo user for demonstration purposes only:
230-
231-
- Demo Author
232-
- Email: `demo-author@payloadcms.com`
233-
- Password: `password`
234-
235-
> NOTICE: seeding the database is destructive because it drops your current database to populate a fresh one from the seed template. Only run this command if you are starting a new project or can afford to lose your current data.
236-
237-
## Production
238-
239-
To run Payload in production, you need to build and start the Admin panel. To do so, follow these steps:
240-
241-
1. Invoke the `next build` script by running `pnpm build` or `npm run build` in your project root. This creates a `.next` directory with a production-ready admin bundle.
242-
1. Finally run `pnpm start` or `npm run start` to run Node in production and serve Payload from the `.build` directory.
243-
1. When you're ready to go live, see Deployment below for more details.
244-
245-
### Deploying to Vercel
246-
247-
This template can also be deployed to Vercel for free. You can get started by choosing the Vercel DB adapter during the setup of the template or by manually installing and configuring it:
28+
### 丢弃本地更新
24829

24930
```bash
250-
pnpm add @payloadcms/db-vercel-postgres
251-
```
252-
253-
```ts
254-
// payload.config.ts
255-
import { vercelPostgresAdapter } from '@payloadcms/db-vercel-postgres'
31+
# 先移除所有未跟踪的文件和目录
32+
git clean -fd
25633

257-
export default buildConfig({
258-
// ...
259-
db: vercelPostgresAdapter({
260-
pool: {
261-
connectionString: process.env.POSTGRES_URL || '',
262-
},
263-
}),
264-
// ...
34+
# 再重置已跟踪文件
35+
git reset --hard HEAD
26536
```
266-
267-
We also support Vercel's blob storage:
268-
269-
```bash
270-
pnpm add @payloadcms/storage-vercel-blob
271-
```
272-
273-
```ts
274-
// payload.config.ts
275-
import { vercelBlobStorage } from '@payloadcms/storage-vercel-blob'
276-
277-
export default buildConfig({
278-
// ...
279-
plugins: [
280-
vercelBlobStorage({
281-
collections: {
282-
[Media.slug]: true,
283-
},
284-
token: process.env.BLOB_READ_WRITE_TOKEN || '',
285-
}),
286-
],
287-
// ...
288-
```
289-
290-
There is also a simplified [one click deploy](https://github.com/payloadcms/payload/tree/templates/with-vercel-postgres) to Vercel should you need it.
291-
292-
### Self-hosting
293-
294-
Before deploying your app, you need to:
295-
296-
1. Ensure your app builds and serves in production. See [Production](#production) for more details.
297-
2. You can then deploy Payload as you would any other Node.js or Next.js application either directly on a VPS, DigitalOcean's Apps Platform, via Coolify or more. More guides coming soon.
298-
299-
You can also deploy your app manually, check out the [deployment documentation](https://payloadcms.com/docs/production/deployment) for full details.
300-
301-
## Questions
302-
303-
If you have any issues or questions, reach out to us on [Discord](https://discord.com/invite/payload) or start a [GitHub discussion](https://github.com/payloadcms/payload/discussions).

src/migrations/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import * as migration_20251229_delete_feeds from './20251229_delete_feeds';
2-
import * as migration_20260106_184630 from './20260106_184630';
1+
import * as migration_20260106_184630 from './20260106_184630'
32

43
export const migrations = [
5-
{
6-
up: migration_20251229_delete_feeds.up,
7-
down: migration_20251229_delete_feeds.down,
8-
name: '20251229_delete_feeds',
9-
},
104
{
115
up: migration_20260106_184630.up,
126
down: migration_20260106_184630.down,
13-
name: '20260106_184630'
7+
name: '20260106_184630',
148
},
15-
];
9+
]

0 commit comments

Comments
 (0)