diff --git a/templates/website/.env.example b/templates/website/.env.example index dd13db6e1..d7a850aba 100644 --- a/templates/website/.env.example +++ b/templates/website/.env.example @@ -4,17 +4,5 @@ DATABASE_URI=mongodb://127.0.0.1/payload-template-website # Used to encrypt JWT tokens PAYLOAD_SECRET=YOUR_SECRET_HERE -# Used to format links and URLs -PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000 +# Used to configure CORS, format links and more. No trailing slash NEXT_PUBLIC_SERVER_URL=http://localhost:3000 - -# Allow robots to index the site (optional) -NEXT_PUBLIC_IS_LIVE= - -# Used to preview drafts -PAYLOAD_PUBLIC_DRAFT_SECRET=demo-draft-secret -NEXT_PRIVATE_DRAFT_SECRET=demo-draft-secret - -# Used to revalidate static pages -REVALIDATION_KEY=demo-revalation-key -NEXT_PRIVATE_REVALIDATION_KEY=demo-revalation-key diff --git a/templates/website/README.md b/templates/website/README.md index 5532fdb03..93e4b6635 100644 --- a/templates/website/README.md +++ b/templates/website/README.md @@ -6,7 +6,7 @@ This template is right for you if you are working on: - A personal or enterprise-grade website, blog, or portfolio - A content publishing platform with a fully featured publication workflow -- A lead generation website with premium content gated behind authentication +- Exploring the capabilities of Payload Core features: @@ -36,13 +36,17 @@ Go to Payload Cloud and [clone this template](https://payloadcms.com/new/clone/w Use the `create-payload-app` CLI to clone this template directly to your machine: - npx create-payload-app@beta my-project -t website +```bash +pnpx create-payload-app@beta my-project -t website +``` #### Method 3 Use the `git` CLI to clone this template directly to your machine: - git clone -n --depth=1 --filter=tree:0 https://github.com/payloadcms/payload my-project && cd my-project && git sparse-checkout set --no-cone templates/website && git checkout && rm -rf .git && git init && git add . && git mv -f templates/website/{.,}* . && git add . && git commit -m "Initial commit" +```bash +git clone -n --depth=1 --filter=tree:0 https://github.com/payloadcms/payload my-project && cd my-project && git sparse-checkout set --no-cone templates/website && git checkout && rm -rf .git && git init && git add . && git mv -f templates/website/{.,}* . && git add . && git commit -m "Initial commit" +``` ### Development @@ -77,7 +81,7 @@ See the [Collections](https://payloadcms.com/docs/beta/configuration/collections - #### Media - This is the uploads enabled collection used by pages, posts, and projects to contain media like images, videos, downloads, and other assets. + 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. - #### Categories @@ -137,6 +141,10 @@ In addition to draft previews you can also enable live preview to view your end This template comes pre-configured with the official [Payload SEO Plugin](https://payloadcms.com/docs/beta/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. +## Search + +This template also pre-configured with the official [Payload Saerch Plugin](https://payloadcms.com/docs/beta/plugins/search) to showcase how SSR search features can easily be implemented into Next.js with Payload. See [Website](#website) for more details. + ## Redirects 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/beta/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. @@ -153,13 +161,13 @@ Core features: - [Payload Admin Bar](https://github.com/payloadcms/payload-admin-bar) - [TailwindCSS styling](https://tailwindcss.com/) - [shadcn/ui components](https://ui.shadcn.com/) -- Authentication +- User Accounts and Authentication - Fully featured blog - Publication workflow -- User accounts - Dark mode - Pre-made layout building blocks - SEO +- Search - Redirects - Live preview @@ -207,14 +215,57 @@ The easiest way to deploy your project is to use [Payload Cloud](https://payload ### Deploying to Vercel -Coming soon. +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: + +```bash +pnpm add @payloadcms/db-vercel-postgres +``` + +```ts +// payload.config.ts +import { vercelPostgresAdapter } from '@payloadcms/db-vercel-postgres' + +export default buildConfig({ + // ... + db: vercelPostgresAdapter({ + pool: { + connectionString: process.env.POSTGRES_URL || '', + }, + }), + // ... +``` + +We also support Vercel's blob storage: + +```bash +pnpm add @payloadcms/storage-vercel-blob +``` + +```ts +// payload.config.ts +import { vercelBlobStorage } from '@payloadcms/storage-vercel-blob' + +export default buildConfig({ + // ... + plugins: [ + vercelBlobStorage({ + collections: { + [Media.slug]: true, + }, + token: process.env.BLOB_READ_WRITE_TOKEN || '', + }), + ], + // ... +``` + +There is also a simplified [one click deploy](https://github.com/payloadcms/payload/tree/beta/templates/with-vercel-postgres) to Vercel should you need it. ### Self-hosting Before deploying your app, you need to: 1. Ensure your app builds and serves in production. See [Production](#production) for more details. -2. Serve it from a +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. You can also deploy your app manually, check out the [deployment documentation](https://payloadcms.com/docs/beta/production/deployment) for full details. diff --git a/templates/website/src/collections/Media.ts b/templates/website/src/collections/Media.ts index d78b8a6db..407ef9bb4 100644 --- a/templates/website/src/collections/Media.ts +++ b/templates/website/src/collections/Media.ts @@ -41,5 +41,32 @@ export const Media: CollectionConfig = { upload: { // Upload to the public/media directory in Next.js making them publicly accessible even outside of Payload staticDir: path.resolve(dirname, '../../public/media'), + imageSizes: [ + { + name: 'square', + width: 500, + height: 500, + }, + { + name: 'thumbnail', + width: 300, + }, + { + name: 'small', + width: 600, + }, + { + name: 'medium', + width: 900, + }, + { + name: 'large', + width: 1400, + }, + { + name: 'xlarge', + width: 1400, + }, + ], }, } diff --git a/templates/website/src/environment.d.ts b/templates/website/src/environment.d.ts new file mode 100644 index 000000000..8c77e6200 --- /dev/null +++ b/templates/website/src/environment.d.ts @@ -0,0 +1,13 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + PAYLOAD_SECRET: string + DATABASE_URI: string + NEXT_PUBLIC_SERVER_URL: string + } + } +} + +// If this file has no import/export statements (i.e. is a script) +// convert it into a module by adding an empty export statement. +export {} diff --git a/templates/website/src/payload-types.ts b/templates/website/src/payload-types.ts index 48684f21c..62eb3dd59 100644 --- a/templates/website/src/payload-types.ts +++ b/templates/website/src/payload-types.ts @@ -24,7 +24,7 @@ export interface Config { 'payload-preferences': PayloadPreference; 'payload-migrations': PayloadMigration; }; - collectionsSelect: { + collectionsSelect?: { pages: PagesSelect | PagesSelect; posts: PostsSelect | PostsSelect; media: MediaSelect | MediaSelect; @@ -45,7 +45,7 @@ export interface Config { header: Header; footer: Footer; }; - globalsSelect: { + globalsSelect?: { header: HeaderSelect | HeaderSelect; footer: FooterSelect | FooterSelect; }; @@ -164,6 +164,56 @@ export interface Media { height?: number | null; focalX?: number | null; focalY?: number | null; + sizes?: { + square?: { + url?: string | null; + width?: number | null; + height?: number | null; + mimeType?: string | null; + filesize?: number | null; + filename?: string | null; + }; + thumbnail?: { + url?: string | null; + width?: number | null; + height?: number | null; + mimeType?: string | null; + filesize?: number | null; + filename?: string | null; + }; + small?: { + url?: string | null; + width?: number | null; + height?: number | null; + mimeType?: string | null; + filesize?: number | null; + filename?: string | null; + }; + medium?: { + url?: string | null; + width?: number | null; + height?: number | null; + mimeType?: string | null; + filesize?: number | null; + filename?: string | null; + }; + large?: { + url?: string | null; + width?: number | null; + height?: number | null; + mimeType?: string | null; + filesize?: number | null; + filename?: string | null; + }; + xlarge?: { + url?: string | null; + width?: number | null; + height?: number | null; + mimeType?: string | null; + filesize?: number | null; + filename?: string | null; + }; + }; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -888,6 +938,70 @@ export interface MediaSelect { height?: T; focalX?: T; focalY?: T; + sizes?: + | T + | { + square?: + | T + | { + url?: T; + width?: T; + height?: T; + mimeType?: T; + filesize?: T; + filename?: T; + }; + thumbnail?: + | T + | { + url?: T; + width?: T; + height?: T; + mimeType?: T; + filesize?: T; + filename?: T; + }; + small?: + | T + | { + url?: T; + width?: T; + height?: T; + mimeType?: T; + filesize?: T; + filename?: T; + }; + medium?: + | T + | { + url?: T; + width?: T; + height?: T; + mimeType?: T; + filesize?: T; + filename?: T; + }; + large?: + | T + | { + url?: T; + width?: T; + height?: T; + mimeType?: T; + filesize?: T; + filename?: T; + }; + xlarge?: + | T + | { + url?: T; + width?: T; + height?: T; + mimeType?: T; + filesize?: T; + filename?: T; + }; + }; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -1287,4 +1401,4 @@ export interface Auth { declare module 'payload' { export interface GeneratedTypes extends Config {} -} +} \ No newline at end of file diff --git a/templates/website/src/payload.config.ts b/templates/website/src/payload.config.ts index ff570006e..a3a447f9b 100644 --- a/templates/website/src/payload.config.ts +++ b/templates/website/src/payload.config.ts @@ -120,12 +120,11 @@ export default buildConfig({ }), // database-adapter-config-start db: mongooseAdapter({ - url: process.env.DATABASE_URI!, + url: process.env.DATABASE_URI, }), // database-adapter-config-end collections: [Pages, Posts, Media, Categories, Users], - cors: [process.env.PAYLOAD_PUBLIC_SERVER_URL || ''].filter(Boolean), - csrf: [process.env.PAYLOAD_PUBLIC_SERVER_URL || ''].filter(Boolean), + cors: [process.env.NEXT_PUBLIC_SERVER_URL || ''].filter(Boolean), endpoints: [ // The seed endpoint is used to populate the database with some example data // You should delete this endpoint before deploying your site to production @@ -203,7 +202,7 @@ export default buildConfig({ }), payloadCloudPlugin(), // storage-adapter-placeholder ], - secret: process.env.PAYLOAD_SECRET!, + secret: process.env.PAYLOAD_SECRET, sharp, typescript: { outputFile: path.resolve(dirname, 'payload-types.ts'),