payload-next-starter 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/setup.js CHANGED
@@ -20,7 +20,7 @@ if (!existsSync(join(targetDir, 'package.json'))) {
20
20
 
21
21
  const pkg = JSON.parse(readFileSync(join(targetDir, 'package.json'), 'utf8'))
22
22
  if (!pkg.dependencies?.next) {
23
- console.error('❌ This doesn\'t appear to be a Next.js project.')
23
+ console.error("❌ This doesn't appear to be a Next.js project.")
24
24
  process.exit(1)
25
25
  }
26
26
 
@@ -42,27 +42,43 @@ try {
42
42
 
43
43
  // Copy payload.config.ts
44
44
  if (existsSync(join(templatesDir, 'payload.config.ts'))) {
45
- copyFileSync(
46
- join(templatesDir, 'payload.config.ts'),
47
- join(targetDir, 'src/payload.config.ts')
48
- )
45
+ copyFileSync(join(templatesDir, 'payload.config.ts'), join(targetDir, 'src/payload.config.ts'))
49
46
  console.log(' ✓ payload.config.ts')
50
47
  }
51
48
 
52
49
  // Copy collections
53
50
  if (existsSync(join(templatesDir, 'collections'))) {
54
- cpSync(join(templatesDir, 'collections'), join(targetDir, 'src/collections'), { recursive: true, force: true })
51
+ cpSync(join(templatesDir, 'collections'), join(targetDir, 'src/collections'), {
52
+ recursive: true,
53
+ force: true,
54
+ })
55
55
  console.log(' ✓ collections/')
56
56
  }
57
57
 
58
58
  // Copy app routes
59
59
  if (existsSync(join(templatesDir, 'app/(payload)'))) {
60
- cpSync(join(templatesDir, 'app/(payload)'), join(targetDir, 'src/app/(payload)'), { recursive: true, force: true })
60
+ cpSync(join(templatesDir, 'app/(payload)'), join(targetDir, 'src/app/(payload)'), {
61
+ recursive: true,
62
+ force: true,
63
+ })
61
64
  console.log(' ✓ app/(payload)/')
62
65
  }
63
66
 
67
+ // Copy frontend pages
68
+ if (existsSync(join(templatesDir, 'app/(frontend)'))) {
69
+ mkdirSync(join(targetDir, 'src/app/(frontend)'), { recursive: true })
70
+ cpSync(join(templatesDir, 'app/(frontend)'), join(targetDir, 'src/app/(frontend)'), {
71
+ recursive: true,
72
+ force: true,
73
+ })
74
+ console.log(' ✓ Frontend pages (about-us, contact-us, share)/')
75
+ }
76
+
64
77
  if (existsSync(join(templatesDir, 'app/api/[...payload]'))) {
65
- cpSync(join(templatesDir, 'app/api/[...payload]'), join(targetDir, 'src/app/api/[...payload]'), { recursive: true, force: true })
78
+ cpSync(join(templatesDir, 'app/api/[...payload]'), join(targetDir, 'src/app/api/[...payload]'), {
79
+ recursive: true,
80
+ force: true,
81
+ })
66
82
  console.log(' ✓ app/api/[...payload]/')
67
83
  }
68
84
 
@@ -75,16 +91,19 @@ const deps = [
75
91
  '@payloadcms/richtext-lexical',
76
92
  '@payloadcms/ui',
77
93
  'dotenv',
78
- 'cross-env'
94
+ 'cross-env',
79
95
  ]
80
96
 
81
97
  try {
82
- const pkgManager = existsSync(join(targetDir, 'pnpm-lock.yaml')) ? 'pnpm' :
83
- existsSync(join(targetDir, 'yarn.lock')) ? 'yarn' : 'npm'
98
+ const pkgManager = existsSync(join(targetDir, 'pnpm-lock.yaml'))
99
+ ? 'pnpm'
100
+ : existsSync(join(targetDir, 'yarn.lock'))
101
+ ? 'yarn'
102
+ : 'npm'
84
103
 
85
104
  execSync(`${pkgManager} add ${deps.join(' ')}`, {
86
105
  cwd: targetDir,
87
- stdio: 'inherit'
106
+ stdio: 'inherit',
88
107
  })
89
108
  console.log('✓ Dependencies installed\n')
90
109
  } catch (e) {
@@ -116,24 +135,30 @@ export default withPayload(nextConfig)
116
135
  }
117
136
  } else {
118
137
  console.log(' ⚠ No next.config found, creating one...')
119
- writeFileSync(join(targetDir, 'next.config.ts'), `import { withPayload } from '@payloadcms/next/withPayload'
138
+ writeFileSync(
139
+ join(targetDir, 'next.config.ts'),
140
+ `import { withPayload } from '@payloadcms/next/withPayload'
120
141
 
121
142
  const nextConfig = {
122
143
  // your config
123
144
  }
124
145
 
125
146
  export default withPayload(nextConfig)
126
- `)
147
+ `,
148
+ )
127
149
  console.log(' ✓ next.config.ts created\n')
128
150
  }
129
151
 
130
152
  // Create .env.example
131
153
  if (!existsSync(join(targetDir, '.env'))) {
132
- writeFileSync(join(targetDir, '.env.example'), `# PayloadCMS
154
+ writeFileSync(
155
+ join(targetDir, '.env.example'),
156
+ `# PayloadCMS
133
157
  DATABASE_URI=postgresql://user:password@host:5432/database
134
158
  PAYLOAD_SECRET=your-secret-key-here-at-least-16-chars
135
159
  NEXT_PUBLIC_SERVER_URL=http://localhost:3000
136
- `)
160
+ `,
161
+ )
137
162
  console.log(' ✓ .env.example created')
138
163
  }
139
164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload-next-starter",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "PayloadCMS starter for Next.js - install into any Next.js app",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,22 @@
1
+ import React from 'react'
2
+
3
+ export default function AboutUsPage() {
4
+ return (
5
+ <div className="about-us">
6
+ <div className="content">
7
+ <h1>About Us</h1>
8
+ <p>
9
+ Welcome to our company. We are dedicated to delivering exceptional
10
+ products and services that meet the needs of our customers. Our team
11
+ is passionate about innovation and committed to excellence.
12
+ </p>
13
+ <p>
14
+ Founded with a vision to make a difference, we have grown into a
15
+ trusted partner for businesses and individuals alike. Our mission is
16
+ to create value through quality, integrity, and customer-focused
17
+ solutions.
18
+ </p>
19
+ </div>
20
+ </div>
21
+ )
22
+ }
@@ -0,0 +1,49 @@
1
+ import React from 'react'
2
+
3
+ export default function ContactUsPage() {
4
+ return (
5
+ <div className="contact-us">
6
+ <div className="content">
7
+ <h1>Contact Us</h1>
8
+ <p>
9
+ We would love to hear from you. Please reach out to us using the
10
+ information below or fill out the contact form.
11
+ </p>
12
+
13
+ <div className="contact-info">
14
+ <h2>Get in Touch</h2>
15
+ <ul>
16
+ <li>
17
+ <strong>Email:</strong> contact@example.com
18
+ </li>
19
+ <li>
20
+ <strong>Phone:</strong> +1 (555) 123-4567
21
+ </li>
22
+ <li>
23
+ <strong>Address:</strong> 123 Main Street, City, State 12345
24
+ </li>
25
+ </ul>
26
+ </div>
27
+
28
+ <div className="contact-form">
29
+ <h2>Send us a Message</h2>
30
+ <form>
31
+ <div className="form-group">
32
+ <label htmlFor="name">Name</label>
33
+ <input type="text" id="name" name="name" placeholder="Your name" />
34
+ </div>
35
+ <div className="form-group">
36
+ <label htmlFor="email">Email</label>
37
+ <input type="email" id="email" name="email" placeholder="Your email" />
38
+ </div>
39
+ <div className="form-group">
40
+ <label htmlFor="message">Message</label>
41
+ <textarea id="message" name="message" rows={5} placeholder="Your message"></textarea>
42
+ </div>
43
+ <button type="submit">Send Message</button>
44
+ </form>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ )
49
+ }
@@ -0,0 +1,59 @@
1
+ import { headers as getHeaders } from 'next/headers.js'
2
+ import Image from 'next/image'
3
+ import { getPayload } from 'payload'
4
+ import React from 'react'
5
+ import { fileURLToPath } from 'url'
6
+
7
+ import config from '@/payload.config'
8
+ import './styles.css'
9
+
10
+ export default async function HomePage() {
11
+ const headers = await getHeaders()
12
+ const payloadConfig = await config
13
+ const payload = await getPayload({ config: payloadConfig })
14
+ const { user } = await payload.auth({ headers })
15
+
16
+ const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
17
+
18
+ return (
19
+ <div className="home">
20
+ <div className="content">
21
+ <picture>
22
+ <source srcSet="https://raw.githubusercontent.com/payloadcms/payload/main/packages/ui/src/assets/payload-favicon.svg" />
23
+ <Image
24
+ alt="Payload Logo"
25
+ height={65}
26
+ src="https://raw.githubusercontent.com/payloadcms/payload/main/packages/ui/src/assets/payload-favicon.svg"
27
+ width={65}
28
+ />
29
+ </picture>
30
+ {!user && <h1>Welcome to your new project. Magically TESt</h1>}
31
+ {user && <h1>Welcome back, {user.email}</h1>}
32
+ <div className="links">
33
+ <a
34
+ className="admin"
35
+ href={payloadConfig.routes.admin}
36
+ rel="noopener noreferrer"
37
+ target="_blank"
38
+ >
39
+ Go to admin panel
40
+ </a>
41
+ <a
42
+ className="docs"
43
+ href="https://payloadcms.com/docs"
44
+ rel="noopener noreferrer"
45
+ target="_blank"
46
+ >
47
+ Documentation
48
+ </a>
49
+ </div>
50
+ </div>
51
+ <div className="footer">
52
+ <p>Update this page by editing</p>
53
+ <a className="codeLink" href={fileURL}>
54
+ <code>app/(frontend)/page.tsx</code>
55
+ </a>
56
+ </div>
57
+ </div>
58
+ )
59
+ }
@@ -0,0 +1,72 @@
1
+ import React from 'react'
2
+
3
+ export default function SharePage() {
4
+ return (
5
+ <div className="share">
6
+ <div className="content">
7
+ <h1>Share</h1>
8
+ <p>
9
+ Share our content with your friends and followers. Spread the word
10
+ and help us grow our community.
11
+ </p>
12
+
13
+ <div className="share-sections">
14
+ <div className="share-card">
15
+ <h2>Social Media</h2>
16
+ <p>Follow us and share our posts on your favorite platforms:</p>
17
+ <ul>
18
+ <li>
19
+ <a href="https://twitter.com/share" target="_blank" rel="noopener noreferrer">
20
+ Twitter
21
+ </a>
22
+ </li>
23
+ <li>
24
+ <a href="https://facebook.com/share" target="_blank" rel="noopener noreferrer">
25
+ Facebook
26
+ </a>
27
+ </li>
28
+ <li>
29
+ <a href="https://linkedin.com/share" target="_blank" rel="noopener noreferrer">
30
+ LinkedIn
31
+ </a>
32
+ </li>
33
+ <li>
34
+ <a href="https://instagram.com" target="_blank" rel="noopener noreferrer">
35
+ Instagram
36
+ </a>
37
+ </li>
38
+ </ul>
39
+ </div>
40
+
41
+ <div className="share-card">
42
+ <h2>Refer a Friend</h2>
43
+ <p>
44
+ Know someone who would benefit from our services? Share your
45
+ unique referral link and earn rewards.
46
+ </p>
47
+ <div className="referral-box">
48
+ <input
49
+ type="text"
50
+ value="https://example.com/ref/YOUR-CODE"
51
+ readOnly
52
+ />
53
+ <button>Copy Link</button>
54
+ </div>
55
+ </div>
56
+
57
+ <div className="share-card">
58
+ <h2>Newsletter</h2>
59
+ <p>
60
+ Stay updated with our latest news and updates. Subscribe to our
61
+ newsletter and share it with others.
62
+ </p>
63
+ <form className="newsletter-form">
64
+ <input type="email" placeholder="Enter your email" />
65
+ <button type="submit">Subscribe</button>
66
+ </form>
67
+ </div>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ )
72
+ }
@@ -0,0 +1,164 @@
1
+ :root {
2
+ --font-mono: 'Roboto Mono', monospace;
3
+ }
4
+
5
+ * {
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ html {
10
+ font-size: 18px;
11
+ line-height: 32px;
12
+
13
+ background: rgb(0, 0, 0);
14
+ -webkit-font-smoothing: antialiased;
15
+ }
16
+
17
+ html,
18
+ body,
19
+ #app {
20
+ height: 100%;
21
+ }
22
+
23
+ body {
24
+ font-family: system-ui;
25
+ font-size: 18px;
26
+ line-height: 32px;
27
+
28
+ margin: 0;
29
+ color: rgb(1000, 1000, 1000);
30
+
31
+ @media (max-width: 1024px) {
32
+ font-size: 15px;
33
+ line-height: 24px;
34
+ }
35
+ }
36
+
37
+ img {
38
+ max-width: 100%;
39
+ height: auto;
40
+ display: block;
41
+ }
42
+
43
+ h1 {
44
+ margin: 40px 0;
45
+ font-size: 64px;
46
+ line-height: 70px;
47
+ font-weight: bold;
48
+
49
+ @media (max-width: 1024px) {
50
+ margin: 24px 0;
51
+ font-size: 42px;
52
+ line-height: 42px;
53
+ }
54
+
55
+ @media (max-width: 768px) {
56
+ font-size: 38px;
57
+ line-height: 38px;
58
+ }
59
+
60
+ @media (max-width: 400px) {
61
+ font-size: 32px;
62
+ line-height: 32px;
63
+ }
64
+ }
65
+
66
+ p {
67
+ margin: 24px 0;
68
+
69
+ @media (max-width: 1024px) {
70
+ margin: calc(var(--base) * 0.75) 0;
71
+ }
72
+ }
73
+
74
+ a {
75
+ color: currentColor;
76
+
77
+ &:focus {
78
+ opacity: 0.8;
79
+ outline: none;
80
+ }
81
+
82
+ &:active {
83
+ opacity: 0.7;
84
+ outline: none;
85
+ }
86
+ }
87
+
88
+ svg {
89
+ vertical-align: middle;
90
+ }
91
+
92
+ .home {
93
+ display: flex;
94
+ flex-direction: column;
95
+ justify-content: space-between;
96
+ align-items: center;
97
+ height: 100vh;
98
+ padding: 45px;
99
+ max-width: 1024px;
100
+ margin: 0 auto;
101
+ overflow: hidden;
102
+
103
+ @media (max-width: 400px) {
104
+ padding: 24px;
105
+ }
106
+
107
+ .content {
108
+ display: flex;
109
+ flex-direction: column;
110
+ align-items: center;
111
+ justify-content: center;
112
+ flex-grow: 1;
113
+
114
+ h1 {
115
+ text-align: center;
116
+ }
117
+ }
118
+
119
+ .links {
120
+ display: flex;
121
+ align-items: center;
122
+ gap: 12px;
123
+
124
+ a {
125
+ text-decoration: none;
126
+ padding: 0.25rem 0.5rem;
127
+ border-radius: 4px;
128
+ }
129
+
130
+ .admin {
131
+ color: rgb(0, 0, 0);
132
+ background: rgb(1000, 1000, 1000);
133
+ border: 1px solid rgb(0, 0, 0);
134
+ }
135
+
136
+ .docs {
137
+ color: rgb(1000, 1000, 1000);
138
+ background: rgb(0, 0, 0);
139
+ border: 1px solid rgb(1000, 1000, 1000);
140
+ }
141
+ }
142
+
143
+ .footer {
144
+ display: flex;
145
+ align-items: center;
146
+ gap: 8px;
147
+
148
+ @media (max-width: 1024px) {
149
+ flex-direction: column;
150
+ gap: 6px;
151
+ }
152
+
153
+ p {
154
+ margin: 0;
155
+ }
156
+
157
+ .codeLink {
158
+ text-decoration: none;
159
+ padding: 0 0.5rem;
160
+ background: rgb(60, 60, 60);
161
+ border-radius: 4px;
162
+ }
163
+ }
164
+ }