create-lx2-app 0.7.1 → 0.8.0
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/dist/index.js +29 -25
- package/package.json +23 -17
- package/template/base/{next.config.mjs → next.config.ts} +4 -3
- package/template/packages/config/drizzle/with-mysql.ts +12 -0
- package/template/packages/config/drizzle/with-postgres.ts +12 -0
- package/template/packages/config/drizzle/with-sqlite.ts +12 -0
- package/template/packages/config/tsconfig/base.json +1 -7
- package/template/packages/config/tsconfig/with-payload.json +1 -7
- package/template/packages/src/app/api/auth/[...betterauth]/route.ts +1 -1
- package/template/packages/src/app/page/with-authjs-drizzle.tsx +222 -0
- package/template/packages/src/app/page/with-authjs-prisma.tsx +21 -9
- package/template/packages/src/app/page/with-authjs.tsx +16 -8
- package/template/packages/src/app/page/with-better-auth-drizzle.tsx +234 -0
- package/template/packages/src/app/page/with-better-auth-prisma.tsx +7 -3
- package/template/packages/src/app/page/with-better-auth.tsx +2 -2
- package/template/packages/src/app/page/with-drizzle.tsx +172 -0
- package/template/packages/src/app/page/with-payload.tsx +2 -4
- package/template/packages/src/app/page/with-prisma.tsx +2 -2
- package/template/packages/src/server/auth/config/authjs-with-drizzle.ts +51 -0
- package/template/packages/src/server/auth/config/better-auth-with-drizzle.ts +20 -0
- package/template/packages/src/server/auth/config/better-auth-with-prisma.ts +1 -0
- package/template/packages/src/server/db/index-drizzle/with-mysql.ts +19 -0
- package/template/packages/src/server/db/index-drizzle/with-postgres.ts +19 -0
- package/template/packages/src/server/db/index-drizzle/with-sqlite.ts +20 -0
- package/template/packages/src/server/db/schema-drizzle/base-mysql.ts +27 -0
- package/template/packages/src/server/db/schema-drizzle/base-postgres.ts +27 -0
- package/template/packages/src/server/db/schema-drizzle/base-sqlite.ts +27 -0
- package/template/packages/src/server/db/schema-drizzle/with-authjs-mysql.ts +138 -0
- package/template/packages/src/server/db/schema-drizzle/with-authjs-postgres.ts +138 -0
- package/template/packages/src/server/db/schema-drizzle/with-authjs-sqlite.ts +138 -0
- package/template/packages/src/server/db/schema-drizzle/with-better-auth-mysql.ts +113 -0
- package/template/packages/src/server/db/schema-drizzle/with-better-auth-postgres.ts +113 -0
- package/template/packages/src/server/db/schema-drizzle/with-better-auth-sqlite.ts +113 -0
- package/LICENSE.md +0 -20
- /package/template/base/src/{env.js → env.ts} +0 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { fileURLToPath } from "url"
|
|
2
|
+
import { eq } from "drizzle-orm"
|
|
3
|
+
import { revalidatePath } from "next/cache"
|
|
4
|
+
|
|
5
|
+
import { auth, signIn, signOut } from "@/server/auth"
|
|
6
|
+
import { db } from "@/server/db"
|
|
7
|
+
import { post as postTable } from "@/server/db/schema"
|
|
8
|
+
|
|
9
|
+
export default async function HomePage() {
|
|
10
|
+
const session = await auth()
|
|
11
|
+
const user = session?.user
|
|
12
|
+
|
|
13
|
+
const posts = await db.query.post.findMany()
|
|
14
|
+
|
|
15
|
+
const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<main className="mx-auto flex h-screen max-w-5xl flex-col items-center justify-between overflow-hidden p-6 sm:p-[45px]">
|
|
19
|
+
<header className="ml-auto">
|
|
20
|
+
{user ? (
|
|
21
|
+
<button
|
|
22
|
+
onClick={async () => {
|
|
23
|
+
"use server"
|
|
24
|
+
await signOut()
|
|
25
|
+
}}
|
|
26
|
+
className="cursor-pointer rounded-md bg-rose-400 px-4 py-2"
|
|
27
|
+
>
|
|
28
|
+
Sign Out
|
|
29
|
+
</button>
|
|
30
|
+
) : (
|
|
31
|
+
<button
|
|
32
|
+
onClick={async () => {
|
|
33
|
+
"use server"
|
|
34
|
+
await signIn("discord")
|
|
35
|
+
}}
|
|
36
|
+
className="cursor-pointer rounded-md bg-purple-400 px-4 py-2"
|
|
37
|
+
>
|
|
38
|
+
Sign In
|
|
39
|
+
</button>
|
|
40
|
+
)}
|
|
41
|
+
</header>
|
|
42
|
+
|
|
43
|
+
<div className="flex grow flex-col items-center justify-center">
|
|
44
|
+
{/* Logo */}
|
|
45
|
+
<picture className="relative">
|
|
46
|
+
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
47
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
48
|
+
<img
|
|
49
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
50
|
+
alt="Logo"
|
|
51
|
+
width={65}
|
|
52
|
+
height={65}
|
|
53
|
+
className="block h-auto max-w-full"
|
|
54
|
+
/>
|
|
55
|
+
</picture>
|
|
56
|
+
|
|
57
|
+
{user ? (
|
|
58
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
59
|
+
Welcome, <span className="capitalize">{user.name}</span>!
|
|
60
|
+
</h1>
|
|
61
|
+
) : (
|
|
62
|
+
<>
|
|
63
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
64
|
+
Lx2 Next.js App
|
|
65
|
+
</h1>
|
|
66
|
+
<p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
67
|
+
Build modern web applications with today's most popular tools
|
|
68
|
+
</p>
|
|
69
|
+
</>
|
|
70
|
+
)}
|
|
71
|
+
|
|
72
|
+
<div className="mt-12 flex items-center gap-3">
|
|
73
|
+
<a
|
|
74
|
+
href="https://create.lx2.dev"
|
|
75
|
+
target="_blank"
|
|
76
|
+
rel="noopener noreferrer"
|
|
77
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
78
|
+
>
|
|
79
|
+
Website
|
|
80
|
+
<svg
|
|
81
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
82
|
+
viewBox="0 0 24 24"
|
|
83
|
+
strokeLinecap="round"
|
|
84
|
+
strokeLinejoin="round"
|
|
85
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
86
|
+
>
|
|
87
|
+
<path d="M7 7h10v10" />
|
|
88
|
+
<path d="M7 17 17 7" />
|
|
89
|
+
</svg>
|
|
90
|
+
</a>
|
|
91
|
+
<a
|
|
92
|
+
href="https://create.lx2.dev/docs"
|
|
93
|
+
target="_blank"
|
|
94
|
+
rel="noopener noreferrer"
|
|
95
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
96
|
+
>
|
|
97
|
+
Docs
|
|
98
|
+
<svg
|
|
99
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
100
|
+
viewBox="0 0 24 24"
|
|
101
|
+
strokeLinecap="round"
|
|
102
|
+
strokeLinejoin="round"
|
|
103
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
104
|
+
>
|
|
105
|
+
<path d="M7 7h10v10" />
|
|
106
|
+
<path d="M7 17 17 7" />
|
|
107
|
+
</svg>
|
|
108
|
+
</a>
|
|
109
|
+
<a
|
|
110
|
+
href="https://github.com/SlickYeet/create-lx2-app"
|
|
111
|
+
target="_blank"
|
|
112
|
+
rel="noopener noreferrer"
|
|
113
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
114
|
+
>
|
|
115
|
+
GitHub
|
|
116
|
+
<svg
|
|
117
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
118
|
+
viewBox="0 0 24 24"
|
|
119
|
+
strokeLinecap="round"
|
|
120
|
+
strokeLinejoin="round"
|
|
121
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
122
|
+
>
|
|
123
|
+
<path d="M7 7h10v10" />
|
|
124
|
+
<path d="M7 17 17 7" />
|
|
125
|
+
</svg>
|
|
126
|
+
</a>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div className="mt-12 flex flex-col items-center gap-3">
|
|
130
|
+
<div className="mb-4">
|
|
131
|
+
<h1 className="mb-4 text-center">
|
|
132
|
+
<span className="text-2xl text-neutral-700 dark:text-neutral-300">
|
|
133
|
+
Posts {posts.length}
|
|
134
|
+
</span>
|
|
135
|
+
</h1>
|
|
136
|
+
|
|
137
|
+
{user ? (
|
|
138
|
+
<form
|
|
139
|
+
action={async (formData: FormData) => {
|
|
140
|
+
"use server"
|
|
141
|
+
|
|
142
|
+
if (!user) throw new Error("Unauthorized")
|
|
143
|
+
|
|
144
|
+
const name =
|
|
145
|
+
formData.get("name")?.toString() ||
|
|
146
|
+
`New Post ${posts.length + 1}`
|
|
147
|
+
|
|
148
|
+
await db.insert(postTable).values({ name })
|
|
149
|
+
|
|
150
|
+
revalidatePath("/")
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
<input
|
|
154
|
+
type="text"
|
|
155
|
+
name="name"
|
|
156
|
+
placeholder="New Post"
|
|
157
|
+
className="h-8 rounded-md border border-neutral-300 px-2 outline-none dark:border-neutral-700 dark:bg-neutral-800"
|
|
158
|
+
/>
|
|
159
|
+
<button
|
|
160
|
+
type="submit"
|
|
161
|
+
className="ml-2 size-8 cursor-pointer rounded-md bg-neutral-200 outline-none hover:opacity-80 focus:opacity-80 dark:bg-neutral-800"
|
|
162
|
+
>
|
|
163
|
+
+
|
|
164
|
+
</button>
|
|
165
|
+
</form>
|
|
166
|
+
) : (
|
|
167
|
+
<p className="text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
168
|
+
Sign in to create posts
|
|
169
|
+
</p>
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<div className="grid w-full grid-cols-1 gap-2 space-y-2 sm:grid-cols-2">
|
|
174
|
+
{posts.map((post) => (
|
|
175
|
+
<div
|
|
176
|
+
key={post.id}
|
|
177
|
+
className="flex h-10 max-w-40 items-center rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
178
|
+
>
|
|
179
|
+
<span className="truncate text-sm text-neutral-700 dark:text-neutral-300">
|
|
180
|
+
{post.name}
|
|
181
|
+
</span>
|
|
182
|
+
{user && (
|
|
183
|
+
<form
|
|
184
|
+
action={async () => {
|
|
185
|
+
"use server"
|
|
186
|
+
|
|
187
|
+
if (!user) throw new Error("Unauthorized")
|
|
188
|
+
|
|
189
|
+
await db
|
|
190
|
+
.delete(postTable)
|
|
191
|
+
.where(eq(postTable.id, post.id))
|
|
192
|
+
|
|
193
|
+
revalidatePath("/")
|
|
194
|
+
}}
|
|
195
|
+
className="ml-auto"
|
|
196
|
+
>
|
|
197
|
+
<button
|
|
198
|
+
type="submit"
|
|
199
|
+
className="ml-2 cursor-pointer rounded-md text-rose-500 outline-none hover:opacity-80 focus:opacity-80"
|
|
200
|
+
>
|
|
201
|
+
x
|
|
202
|
+
</button>
|
|
203
|
+
</form>
|
|
204
|
+
)}
|
|
205
|
+
</div>
|
|
206
|
+
))}
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<div className="flex flex-col items-center gap-1 text-sm text-neutral-600 lg:flex-row lg:gap-2 dark:text-neutral-400">
|
|
212
|
+
<p className="m-0">Get started by editing </p>
|
|
213
|
+
<a
|
|
214
|
+
href={fileURL}
|
|
215
|
+
className="rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
216
|
+
>
|
|
217
|
+
<code>src/app/page.tsx</code>
|
|
218
|
+
</a>
|
|
219
|
+
</div>
|
|
220
|
+
</main>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
@@ -42,9 +42,9 @@ export default async function HomePage() {
|
|
|
42
42
|
{/* Logo */}
|
|
43
43
|
<picture className="relative">
|
|
44
44
|
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
45
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
45
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
46
46
|
<img
|
|
47
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
47
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
48
48
|
alt="Logo"
|
|
49
49
|
width={65}
|
|
50
50
|
height={65}
|
|
@@ -52,12 +52,20 @@ export default async function HomePage() {
|
|
|
52
52
|
/>
|
|
53
53
|
</picture>
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
{user ? (
|
|
56
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
57
|
+
Welcome, <span className="capitalize">{user.name}</span>!
|
|
58
|
+
</h1>
|
|
59
|
+
) : (
|
|
60
|
+
<>
|
|
61
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
62
|
+
Lx2 Next.js App
|
|
63
|
+
</h1>
|
|
64
|
+
<p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
65
|
+
Build modern web applications with today's most popular tools
|
|
66
|
+
</p>
|
|
67
|
+
</>
|
|
68
|
+
)}
|
|
61
69
|
|
|
62
70
|
<div className="mt-12 flex items-center gap-3">
|
|
63
71
|
<a
|
|
@@ -124,7 +132,7 @@ export default async function HomePage() {
|
|
|
124
132
|
</span>
|
|
125
133
|
</h1>
|
|
126
134
|
|
|
127
|
-
{user
|
|
135
|
+
{user ? (
|
|
128
136
|
<form
|
|
129
137
|
action={async (formData: FormData) => {
|
|
130
138
|
"use server"
|
|
@@ -163,6 +171,10 @@ export default async function HomePage() {
|
|
|
163
171
|
+
|
|
164
172
|
</button>
|
|
165
173
|
</form>
|
|
174
|
+
) : (
|
|
175
|
+
<p className="text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
176
|
+
Sign in to create posts
|
|
177
|
+
</p>
|
|
166
178
|
)}
|
|
167
179
|
</div>
|
|
168
180
|
|
|
@@ -38,9 +38,9 @@ export default async function HomePage() {
|
|
|
38
38
|
{/* Logo */}
|
|
39
39
|
<picture className="relative">
|
|
40
40
|
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
41
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
41
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
42
42
|
<img
|
|
43
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
43
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
44
44
|
alt="Logo"
|
|
45
45
|
width={65}
|
|
46
46
|
height={65}
|
|
@@ -48,12 +48,20 @@ export default async function HomePage() {
|
|
|
48
48
|
/>
|
|
49
49
|
</picture>
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
{user ? (
|
|
52
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
53
|
+
Welcome, <span className="capitalize">{user.name}</span>!
|
|
54
|
+
</h1>
|
|
55
|
+
) : (
|
|
56
|
+
<>
|
|
57
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
58
|
+
Lx2 Next.js App
|
|
59
|
+
</h1>
|
|
60
|
+
<p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
61
|
+
Build modern web applications with today's most popular tools
|
|
62
|
+
</p>
|
|
63
|
+
</>
|
|
64
|
+
)}
|
|
57
65
|
|
|
58
66
|
<div className="mt-12 flex items-center gap-3">
|
|
59
67
|
<a
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { fileURLToPath } from "url"
|
|
2
|
+
import { eq } from "drizzle-orm"
|
|
3
|
+
import { revalidatePath } from "next/cache"
|
|
4
|
+
import { headers } from "next/headers"
|
|
5
|
+
import { redirect } from "next/navigation"
|
|
6
|
+
|
|
7
|
+
import { auth } from "@/server/auth"
|
|
8
|
+
import { db } from "@/server/db"
|
|
9
|
+
import { post as postTable } from "@/server/db/schema"
|
|
10
|
+
|
|
11
|
+
export default async function HomePage() {
|
|
12
|
+
const session = await auth.api.getSession({
|
|
13
|
+
headers: await headers(),
|
|
14
|
+
})
|
|
15
|
+
const user = session?.user
|
|
16
|
+
|
|
17
|
+
const posts = await db.query.post.findMany()
|
|
18
|
+
|
|
19
|
+
const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<main className="mx-auto flex h-screen max-w-5xl flex-col items-center justify-between overflow-hidden p-6 sm:p-[45px]">
|
|
23
|
+
<header className="ml-auto">
|
|
24
|
+
{user ? (
|
|
25
|
+
<button
|
|
26
|
+
onClick={async () => {
|
|
27
|
+
"use server"
|
|
28
|
+
await auth.api.signOut({
|
|
29
|
+
headers: await headers(),
|
|
30
|
+
})
|
|
31
|
+
}}
|
|
32
|
+
className="cursor-pointer rounded-md bg-rose-400 px-4 py-2"
|
|
33
|
+
>
|
|
34
|
+
Sign Out
|
|
35
|
+
</button>
|
|
36
|
+
) : (
|
|
37
|
+
<button
|
|
38
|
+
onClick={async () => {
|
|
39
|
+
"use server"
|
|
40
|
+
const response = await auth.api.signInSocial({
|
|
41
|
+
body: {
|
|
42
|
+
provider: "discord",
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
if (!response) {
|
|
46
|
+
throw new Error("Failed to sign in")
|
|
47
|
+
}
|
|
48
|
+
if (response.url) {
|
|
49
|
+
redirect(response.url)
|
|
50
|
+
}
|
|
51
|
+
}}
|
|
52
|
+
className="cursor-pointer rounded-md bg-purple-400 px-4 py-2"
|
|
53
|
+
>
|
|
54
|
+
Sign In
|
|
55
|
+
</button>
|
|
56
|
+
)}
|
|
57
|
+
</header>
|
|
58
|
+
|
|
59
|
+
<div className="flex grow flex-col items-center justify-center">
|
|
60
|
+
{/* Logo */}
|
|
61
|
+
<picture className="relative">
|
|
62
|
+
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
63
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
64
|
+
<img
|
|
65
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
66
|
+
alt="Logo"
|
|
67
|
+
width={65}
|
|
68
|
+
height={65}
|
|
69
|
+
className="block h-auto max-w-full"
|
|
70
|
+
/>
|
|
71
|
+
</picture>
|
|
72
|
+
|
|
73
|
+
{user ? (
|
|
74
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
75
|
+
Welcome, <span className="capitalize">{user.name}</span>!
|
|
76
|
+
</h1>
|
|
77
|
+
) : (
|
|
78
|
+
<>
|
|
79
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
80
|
+
Lx2 Next.js App
|
|
81
|
+
</h1>
|
|
82
|
+
<p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
83
|
+
Build modern web applications with today's most popular tools
|
|
84
|
+
</p>
|
|
85
|
+
</>
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
<div className="mt-12 flex items-center gap-3">
|
|
89
|
+
<a
|
|
90
|
+
href="https://create.lx2.dev"
|
|
91
|
+
target="_blank"
|
|
92
|
+
rel="noopener noreferrer"
|
|
93
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
94
|
+
>
|
|
95
|
+
Website
|
|
96
|
+
<svg
|
|
97
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
98
|
+
viewBox="0 0 24 24"
|
|
99
|
+
strokeLinecap="round"
|
|
100
|
+
strokeLinejoin="round"
|
|
101
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
102
|
+
>
|
|
103
|
+
<path d="M7 7h10v10" />
|
|
104
|
+
<path d="M7 17 17 7" />
|
|
105
|
+
</svg>
|
|
106
|
+
</a>
|
|
107
|
+
<a
|
|
108
|
+
href="https://create.lx2.dev/docs"
|
|
109
|
+
target="_blank"
|
|
110
|
+
rel="noopener noreferrer"
|
|
111
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
112
|
+
>
|
|
113
|
+
Docs
|
|
114
|
+
<svg
|
|
115
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
116
|
+
viewBox="0 0 24 24"
|
|
117
|
+
strokeLinecap="round"
|
|
118
|
+
strokeLinejoin="round"
|
|
119
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
120
|
+
>
|
|
121
|
+
<path d="M7 7h10v10" />
|
|
122
|
+
<path d="M7 17 17 7" />
|
|
123
|
+
</svg>
|
|
124
|
+
</a>
|
|
125
|
+
<a
|
|
126
|
+
href="https://github.com/SlickYeet/create-lx2-app"
|
|
127
|
+
target="_blank"
|
|
128
|
+
rel="noopener noreferrer"
|
|
129
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
130
|
+
>
|
|
131
|
+
GitHub
|
|
132
|
+
<svg
|
|
133
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
134
|
+
viewBox="0 0 24 24"
|
|
135
|
+
strokeLinecap="round"
|
|
136
|
+
strokeLinejoin="round"
|
|
137
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
138
|
+
>
|
|
139
|
+
<path d="M7 7h10v10" />
|
|
140
|
+
<path d="M7 17 17 7" />
|
|
141
|
+
</svg>
|
|
142
|
+
</a>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div className="mt-12 flex flex-col items-center gap-3">
|
|
146
|
+
<div className="mb-4">
|
|
147
|
+
<h1 className="mb-4 text-center">
|
|
148
|
+
<span className="text-2xl text-neutral-700 dark:text-neutral-300">
|
|
149
|
+
Posts {posts.length}
|
|
150
|
+
</span>
|
|
151
|
+
</h1>
|
|
152
|
+
|
|
153
|
+
{user ? (
|
|
154
|
+
<form
|
|
155
|
+
action={async (formData: FormData) => {
|
|
156
|
+
"use server"
|
|
157
|
+
|
|
158
|
+
const name =
|
|
159
|
+
formData.get("name")?.toString() ||
|
|
160
|
+
`New Post ${posts.length + 1}`
|
|
161
|
+
|
|
162
|
+
await db.insert(postTable).values({ name })
|
|
163
|
+
|
|
164
|
+
revalidatePath("/")
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<input
|
|
168
|
+
type="text"
|
|
169
|
+
name="name"
|
|
170
|
+
placeholder="New Post"
|
|
171
|
+
className="h-8 rounded-md border border-neutral-300 px-2 outline-none dark:border-neutral-700 dark:bg-neutral-800"
|
|
172
|
+
/>
|
|
173
|
+
<button
|
|
174
|
+
type="submit"
|
|
175
|
+
className="ml-2 size-8 cursor-pointer rounded-md bg-neutral-200 outline-none hover:opacity-80 focus:opacity-80 dark:bg-neutral-800"
|
|
176
|
+
>
|
|
177
|
+
+
|
|
178
|
+
</button>
|
|
179
|
+
</form>
|
|
180
|
+
) : (
|
|
181
|
+
<p className="text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
182
|
+
Sign in to create posts
|
|
183
|
+
</p>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div className="grid w-full grid-cols-1 gap-2 space-y-2 sm:grid-cols-2">
|
|
188
|
+
{posts.map((post) => (
|
|
189
|
+
<div
|
|
190
|
+
key={post.id}
|
|
191
|
+
className="flex h-10 max-w-40 items-center rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
192
|
+
>
|
|
193
|
+
<span className="truncate text-sm text-neutral-700 dark:text-neutral-300">
|
|
194
|
+
{post.name}
|
|
195
|
+
</span>
|
|
196
|
+
{user && (
|
|
197
|
+
<form
|
|
198
|
+
action={async () => {
|
|
199
|
+
"use server"
|
|
200
|
+
|
|
201
|
+
await db
|
|
202
|
+
.delete(postTable)
|
|
203
|
+
.where(eq(postTable.id, post.id))
|
|
204
|
+
|
|
205
|
+
revalidatePath("/")
|
|
206
|
+
}}
|
|
207
|
+
className="ml-auto"
|
|
208
|
+
>
|
|
209
|
+
<button
|
|
210
|
+
type="submit"
|
|
211
|
+
className="ml-2 cursor-pointer rounded-md text-rose-500 outline-none hover:opacity-80 focus:opacity-80"
|
|
212
|
+
>
|
|
213
|
+
x
|
|
214
|
+
</button>
|
|
215
|
+
</form>
|
|
216
|
+
)}
|
|
217
|
+
</div>
|
|
218
|
+
))}
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
<div className="flex flex-col items-center gap-1 text-sm text-neutral-600 lg:flex-row lg:gap-2 dark:text-neutral-400">
|
|
224
|
+
<p className="m-0">Get started by editing </p>
|
|
225
|
+
<a
|
|
226
|
+
href={fileURL}
|
|
227
|
+
className="rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
228
|
+
>
|
|
229
|
+
<code>src/app/page.tsx</code>
|
|
230
|
+
</a>
|
|
231
|
+
</div>
|
|
232
|
+
</main>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
@@ -58,9 +58,9 @@ export default async function HomePage() {
|
|
|
58
58
|
{/* Logo */}
|
|
59
59
|
<picture className="relative">
|
|
60
60
|
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
61
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
61
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
62
62
|
<img
|
|
63
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
63
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
64
64
|
alt="Logo"
|
|
65
65
|
width={65}
|
|
66
66
|
height={65}
|
|
@@ -148,7 +148,7 @@ export default async function HomePage() {
|
|
|
148
148
|
</span>
|
|
149
149
|
</h1>
|
|
150
150
|
|
|
151
|
-
{user
|
|
151
|
+
{user ? (
|
|
152
152
|
<form
|
|
153
153
|
action={async (formData: FormData) => {
|
|
154
154
|
"use server"
|
|
@@ -187,6 +187,10 @@ export default async function HomePage() {
|
|
|
187
187
|
+
|
|
188
188
|
</button>
|
|
189
189
|
</form>
|
|
190
|
+
) : (
|
|
191
|
+
<p className="text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
192
|
+
Sign in to create posts
|
|
193
|
+
</p>
|
|
190
194
|
)}
|
|
191
195
|
</div>
|
|
192
196
|
|
|
@@ -54,9 +54,9 @@ export default async function HomePage() {
|
|
|
54
54
|
{/* Logo */}
|
|
55
55
|
<picture className="relative">
|
|
56
56
|
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
57
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
57
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
58
58
|
<img
|
|
59
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
59
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
60
60
|
alt="Logo"
|
|
61
61
|
width={65}
|
|
62
62
|
height={65}
|