create-thexjs-app 0.1.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/LICENSE +21 -0
- package/README.md +1026 -0
- package/dist/index.js +224 -0
- package/package.json +30 -0
- package/templates/basic/components.json +21 -0
- package/templates/basic/content/blog/hello.md +8 -0
- package/templates/basic/public/favicon.ico +0 -0
- package/templates/basic/src/actions/dashboard/greet.ts +3 -0
- package/templates/basic/src/api/auth/login.ts +30 -0
- package/templates/basic/src/api/auth/logout.ts +12 -0
- package/templates/basic/src/api/placeholder/comments.ts +17 -0
- package/templates/basic/src/api/placeholder/posts.ts +20 -0
- package/templates/basic/src/api/placeholder/todos.ts +21 -0
- package/templates/basic/src/api/placeholder/users.ts +12 -0
- package/templates/basic/src/components/Head.tsx +21 -0
- package/templates/basic/src/components/Image.tsx +27 -0
- package/templates/basic/src/components/Link.tsx +16 -0
- package/templates/basic/src/components/ui/badge.tsx +49 -0
- package/templates/basic/src/components/ui/button.tsx +58 -0
- package/templates/basic/src/components/ui/card.tsx +88 -0
- package/templates/basic/src/components/ui/input.tsx +20 -0
- package/templates/basic/src/layouts/main.tsx +38 -0
- package/templates/basic/src/lib/auth.ts +70 -0
- package/templates/basic/src/lib/migrations/001_create_sessions.sql +9 -0
- package/templates/basic/src/lib/placeholder-data.ts +176 -0
- package/templates/basic/src/lib/utils.ts +6 -0
- package/templates/basic/src/pages/_404.tsx +17 -0
- package/templates/basic/src/pages/about.tsx +22 -0
- package/templates/basic/src/pages/blog.tsx +41 -0
- package/templates/basic/src/pages/dashboard/_middleware.ts +16 -0
- package/templates/basic/src/pages/dashboard/index.tsx +84 -0
- package/templates/basic/src/pages/index.tsx +54 -0
- package/templates/basic/src/pages/login.tsx +85 -0
- package/templates/basic/src/pages/placeholder.tsx +194 -0
- package/templates/basic/src/pages/posts/[id].tsx +17 -0
- package/templates/basic/src/styles/globals.css +90 -0
- package/templates/basic/src/x-routes.ts +29 -0
- package/templates/basic/tsconfig.json +11 -0
- package/templates/basic/x.config.ts +10 -0
- package/templates/blog/components.json +20 -0
- package/templates/blog/content/posts/getting-started.md +38 -0
- package/templates/blog/content/posts/hello-world.md +21 -0
- package/templates/blog/content/posts/tailwind-v4.md +31 -0
- package/templates/blog/public/favicon.ico +0 -0
- package/templates/blog/src/components/ui/avatar.tsx +91 -0
- package/templates/blog/src/components/ui/badge.tsx +49 -0
- package/templates/blog/src/components/ui/button.tsx +58 -0
- package/templates/blog/src/components/ui/card.tsx +88 -0
- package/templates/blog/src/components/ui/input.tsx +20 -0
- package/templates/blog/src/layouts/blog.tsx +46 -0
- package/templates/blog/src/layouts/main.tsx +32 -0
- package/templates/blog/src/lib/utils.ts +5 -0
- package/templates/blog/src/pages/about.tsx +36 -0
- package/templates/blog/src/pages/blog/[slug].tsx +56 -0
- package/templates/blog/src/pages/blog/index.tsx +70 -0
- package/templates/blog/src/pages/index.tsx +70 -0
- package/templates/blog/src/styles/globals.css +90 -0
- package/templates/blog/src/x-routes.ts +20 -0
- package/templates/blog/tsconfig.json +5 -0
- package/templates/blog/x.config.ts +6 -0
- package/templates/landing/components.json +20 -0
- package/templates/landing/public/favicon.ico +0 -0
- package/templates/landing/src/components/code-block.tsx +24 -0
- package/templates/landing/src/components/ui/avatar.tsx +91 -0
- package/templates/landing/src/components/ui/badge.tsx +49 -0
- package/templates/landing/src/components/ui/button.tsx +58 -0
- package/templates/landing/src/components/ui/card.tsx +88 -0
- package/templates/landing/src/components/ui/input.tsx +20 -0
- package/templates/landing/src/layouts/main.tsx +48 -0
- package/templates/landing/src/lib/syntax.tsx +366 -0
- package/templates/landing/src/lib/utils.ts +5 -0
- package/templates/landing/src/pages/contact.tsx +95 -0
- package/templates/landing/src/pages/docs/_layout.tsx +109 -0
- package/templates/landing/src/pages/docs/api-routes.tsx +113 -0
- package/templates/landing/src/pages/docs/build-deploy.tsx +124 -0
- package/templates/landing/src/pages/docs/configuration.tsx +121 -0
- package/templates/landing/src/pages/docs/content-collections.tsx +130 -0
- package/templates/landing/src/pages/docs/data-layer.tsx +142 -0
- package/templates/landing/src/pages/docs/getting-started.tsx +119 -0
- package/templates/landing/src/pages/docs/index.tsx +123 -0
- package/templates/landing/src/pages/docs/layouts.tsx +114 -0
- package/templates/landing/src/pages/docs/middleware.tsx +124 -0
- package/templates/landing/src/pages/docs/pages.tsx +135 -0
- package/templates/landing/src/pages/docs/routing.tsx +123 -0
- package/templates/landing/src/pages/docs/server-functions.tsx +123 -0
- package/templates/landing/src/pages/features.tsx +129 -0
- package/templates/landing/src/pages/index.tsx +175 -0
- package/templates/landing/src/styles/globals.css +100 -0
- package/templates/landing/src/x-routes.ts +31 -0
- package/templates/landing/tsconfig.json +5 -0
- package/templates/landing/x.config.ts +2 -0
- package/templates/saas/components.json +20 -0
- package/templates/saas/public/favicon.ico +0 -0
- package/templates/saas/src/actions/dashboard.ts +3 -0
- package/templates/saas/src/components/ui/avatar.tsx +91 -0
- package/templates/saas/src/components/ui/badge.tsx +49 -0
- package/templates/saas/src/components/ui/button.tsx +58 -0
- package/templates/saas/src/components/ui/card.tsx +88 -0
- package/templates/saas/src/components/ui/input.tsx +20 -0
- package/templates/saas/src/layouts/dashboard.tsx +67 -0
- package/templates/saas/src/layouts/main.tsx +38 -0
- package/templates/saas/src/lib/auth.ts +70 -0
- package/templates/saas/src/lib/migrations/001_create_sessions.sql +9 -0
- package/templates/saas/src/lib/utils.ts +5 -0
- package/templates/saas/src/pages/dashboard/_middleware.ts +9 -0
- package/templates/saas/src/pages/dashboard/analytics.tsx +68 -0
- package/templates/saas/src/pages/dashboard/index.tsx +86 -0
- package/templates/saas/src/pages/dashboard/settings.tsx +105 -0
- package/templates/saas/src/pages/index.tsx +110 -0
- package/templates/saas/src/pages/login.tsx +67 -0
- package/templates/saas/src/pages/pricing.tsx +121 -0
- package/templates/saas/src/styles/globals.css +90 -0
- package/templates/saas/src/x-routes.ts +22 -0
- package/templates/saas/tsconfig.json +5 -0
- package/templates/saas/x.config.ts +7 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
const KEYWORDS = new Set([
|
|
4
|
+
"export",
|
|
5
|
+
"default",
|
|
6
|
+
"function",
|
|
7
|
+
"const",
|
|
8
|
+
"let",
|
|
9
|
+
"var",
|
|
10
|
+
"return",
|
|
11
|
+
"import",
|
|
12
|
+
"from",
|
|
13
|
+
"async",
|
|
14
|
+
"await",
|
|
15
|
+
"if",
|
|
16
|
+
"else",
|
|
17
|
+
"for",
|
|
18
|
+
"while",
|
|
19
|
+
"class",
|
|
20
|
+
"interface",
|
|
21
|
+
"type",
|
|
22
|
+
"extends",
|
|
23
|
+
"implements",
|
|
24
|
+
"new",
|
|
25
|
+
"this",
|
|
26
|
+
"true",
|
|
27
|
+
"false",
|
|
28
|
+
"null",
|
|
29
|
+
"undefined",
|
|
30
|
+
"void",
|
|
31
|
+
"throw",
|
|
32
|
+
"try",
|
|
33
|
+
"catch",
|
|
34
|
+
"finally",
|
|
35
|
+
"switch",
|
|
36
|
+
"case",
|
|
37
|
+
"break",
|
|
38
|
+
"continue",
|
|
39
|
+
"typeof",
|
|
40
|
+
"instanceof",
|
|
41
|
+
"in",
|
|
42
|
+
"of",
|
|
43
|
+
"import type",
|
|
44
|
+
"import {",
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
export function highlight(code: string, lang = "tsx"): ReactNode {
|
|
48
|
+
if (lang === "bash" || lang === "terminal") {
|
|
49
|
+
return highlightBash(code);
|
|
50
|
+
}
|
|
51
|
+
if (lang === "tree") {
|
|
52
|
+
return highlightTree(code);
|
|
53
|
+
}
|
|
54
|
+
return highlightCode(code);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function highlightBash(code: string): ReactNode {
|
|
58
|
+
return code.split("\n").map((line, i) => {
|
|
59
|
+
const trimmed = line.trimStart();
|
|
60
|
+
if (trimmed.startsWith("$")) {
|
|
61
|
+
const indent = line.slice(0, line.length - trimmed.length);
|
|
62
|
+
const rest = trimmed.slice(1);
|
|
63
|
+
return (
|
|
64
|
+
<span key={i} className="block">
|
|
65
|
+
{indent}
|
|
66
|
+
<span className="text-[#7ee787]">$</span>
|
|
67
|
+
{rest}
|
|
68
|
+
</span>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
if (trimmed === "" || trimmed.startsWith("//")) {
|
|
72
|
+
return (
|
|
73
|
+
<span key={i} className="block text-[#848d97]">
|
|
74
|
+
{line}
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (trimmed.startsWith(" ")) {
|
|
79
|
+
return (
|
|
80
|
+
<span key={i} className="block text-[#848d97]">
|
|
81
|
+
{line}
|
|
82
|
+
</span>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return (
|
|
86
|
+
<span key={i} className="block">
|
|
87
|
+
{line}
|
|
88
|
+
</span>
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function highlightTree(code: string): ReactNode {
|
|
94
|
+
return code.split("\n").map((line, i) => {
|
|
95
|
+
const s = line.trimStart();
|
|
96
|
+
if (s.endsWith("/")) {
|
|
97
|
+
return (
|
|
98
|
+
<span key={i} className="block text-[#79c0ff]">
|
|
99
|
+
{line}
|
|
100
|
+
</span>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const commentIdx = s.indexOf("//");
|
|
104
|
+
if (commentIdx !== -1) {
|
|
105
|
+
const before = s.slice(0, commentIdx);
|
|
106
|
+
const after = s.slice(commentIdx);
|
|
107
|
+
return (
|
|
108
|
+
<span key={i} className="block">
|
|
109
|
+
{before}
|
|
110
|
+
<span className="text-[#848d97]">{after}</span>
|
|
111
|
+
</span>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return (
|
|
115
|
+
<span key={i} className="block">
|
|
116
|
+
{line}
|
|
117
|
+
</span>
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function highlightCode(code: string): ReactNode {
|
|
123
|
+
const lines = code.split("\n");
|
|
124
|
+
const result: ReactNode[] = [];
|
|
125
|
+
|
|
126
|
+
for (let i = 0; i < lines.length; i++) {
|
|
127
|
+
const line = lines[i];
|
|
128
|
+
if (line === undefined) continue;
|
|
129
|
+
result.push(
|
|
130
|
+
<span key={i} className="block">
|
|
131
|
+
{tokenizeLine(line)}
|
|
132
|
+
</span>,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function tokenizeLine(line: string): ReactNode[] {
|
|
140
|
+
const tokens: ReactNode[] = [];
|
|
141
|
+
let i = 0;
|
|
142
|
+
let key = 0;
|
|
143
|
+
|
|
144
|
+
const flushText = (start: number, end: number) => {
|
|
145
|
+
if (end > start) {
|
|
146
|
+
tokens.push(<span key={key++}>{line.slice(start, end)}</span>);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
while (i < line.length) {
|
|
151
|
+
if (line[i] === " " || line[i] === "\t") {
|
|
152
|
+
const start = i;
|
|
153
|
+
while (i < line.length && (line[i] === " " || line[i] === "\t")) i++;
|
|
154
|
+
tokens.push(line.slice(start, i));
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (line[i] === "/" && line[i + 1] === "/") {
|
|
159
|
+
tokens.push(
|
|
160
|
+
<span key={key++} className="text-[#848d97]">
|
|
161
|
+
{line.slice(i)}
|
|
162
|
+
</span>,
|
|
163
|
+
);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (line[i] === '"') {
|
|
168
|
+
let str = '"';
|
|
169
|
+
i++;
|
|
170
|
+
while (i < line.length) {
|
|
171
|
+
if (line[i] === "\\") {
|
|
172
|
+
str += line[i];
|
|
173
|
+
i++;
|
|
174
|
+
if (i < line.length) {
|
|
175
|
+
str += line[i];
|
|
176
|
+
i++;
|
|
177
|
+
}
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (line[i] === '"') {
|
|
181
|
+
str += '"';
|
|
182
|
+
i++;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
str += line[i];
|
|
186
|
+
i++;
|
|
187
|
+
}
|
|
188
|
+
tokens.push(
|
|
189
|
+
<span key={key++} className="text-[#a5d6ff]">
|
|
190
|
+
{str}
|
|
191
|
+
</span>,
|
|
192
|
+
);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (line[i] === "'") {
|
|
197
|
+
let str = "'";
|
|
198
|
+
i++;
|
|
199
|
+
while (i < line.length) {
|
|
200
|
+
if (line[i] === "\\") {
|
|
201
|
+
str += line[i];
|
|
202
|
+
i++;
|
|
203
|
+
if (i < line.length) {
|
|
204
|
+
str += line[i];
|
|
205
|
+
i++;
|
|
206
|
+
}
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (line[i] === "'") {
|
|
210
|
+
str += "'";
|
|
211
|
+
i++;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
str += line[i];
|
|
215
|
+
i++;
|
|
216
|
+
}
|
|
217
|
+
tokens.push(
|
|
218
|
+
<span key={key++} className="text-[#a5d6ff]">
|
|
219
|
+
{str}
|
|
220
|
+
</span>,
|
|
221
|
+
);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (line[i] === "`") {
|
|
226
|
+
let str = "`";
|
|
227
|
+
i++;
|
|
228
|
+
while (i < line.length) {
|
|
229
|
+
if (line[i] === "\\") {
|
|
230
|
+
str += line[i];
|
|
231
|
+
i++;
|
|
232
|
+
if (i < line.length) {
|
|
233
|
+
str += line[i];
|
|
234
|
+
i++;
|
|
235
|
+
}
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (line[i] === "`") {
|
|
239
|
+
str += "`";
|
|
240
|
+
i++;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
if (line[i] === "$" && line[i + 1] === "{") {
|
|
244
|
+
str += "${";
|
|
245
|
+
i += 2;
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
str += line[i];
|
|
249
|
+
i++;
|
|
250
|
+
}
|
|
251
|
+
tokens.push(
|
|
252
|
+
<span key={key++} className="text-[#a5d6ff]">
|
|
253
|
+
{str}
|
|
254
|
+
</span>,
|
|
255
|
+
);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (
|
|
260
|
+
i < line.length &&
|
|
261
|
+
/[0-9]/.test(line[i]!) &&
|
|
262
|
+
(i === 0 || /[\s([,=*/%+\-!<>|&^~?:;]/.test(line[i - 1]!))
|
|
263
|
+
) {
|
|
264
|
+
let num = "";
|
|
265
|
+
while (i < line.length && /[0-9.]/.test(line[i]!)) {
|
|
266
|
+
num += line[i]!;
|
|
267
|
+
i++;
|
|
268
|
+
}
|
|
269
|
+
tokens.push(
|
|
270
|
+
<span key={key++} className="text-[#79c0ff]">
|
|
271
|
+
{num}
|
|
272
|
+
</span>,
|
|
273
|
+
);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (i < line.length && line[i]! === "<") {
|
|
278
|
+
let tag = "<";
|
|
279
|
+
i++;
|
|
280
|
+
if (i < line.length && line[i]! === "/") {
|
|
281
|
+
tag += "/";
|
|
282
|
+
i++;
|
|
283
|
+
}
|
|
284
|
+
const nameStart = i;
|
|
285
|
+
while (i < line.length && /[a-zA-Z0-9]/.test(line[i]!)) {
|
|
286
|
+
i++;
|
|
287
|
+
}
|
|
288
|
+
const name = line.slice(nameStart, i);
|
|
289
|
+
if (name) {
|
|
290
|
+
tag += name;
|
|
291
|
+
tokens.push(
|
|
292
|
+
<span key={key++} className="text-[#ffa657]">
|
|
293
|
+
{tag}
|
|
294
|
+
</span>,
|
|
295
|
+
);
|
|
296
|
+
} else {
|
|
297
|
+
tokens.push(
|
|
298
|
+
<span key={key++} className="text-[#e6edf3]">
|
|
299
|
+
{tag}
|
|
300
|
+
</span>,
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (i < line.length && line[i]! === "/" && i + 1 < line.length && line[i + 1]! === ">") {
|
|
307
|
+
tokens.push(
|
|
308
|
+
<span key={key++} className="text-[#ffa657]">
|
|
309
|
+
{"/> "}
|
|
310
|
+
</span>,
|
|
311
|
+
);
|
|
312
|
+
i += 1;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (i < line.length && /[a-zA-Z_$]/.test(line[i]!)) {
|
|
317
|
+
let word = "";
|
|
318
|
+
while (i < line.length && /[a-zA-Z0-9_$]/.test(line[i]!)) {
|
|
319
|
+
word += line[i]!;
|
|
320
|
+
i++;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const restTrimmed = line.slice(i).trimStart();
|
|
324
|
+
if (
|
|
325
|
+
restTrimmed.startsWith("=") &&
|
|
326
|
+
!restTrimmed.startsWith("===") &&
|
|
327
|
+
!restTrimmed.startsWith("=>")
|
|
328
|
+
) {
|
|
329
|
+
tokens.push(
|
|
330
|
+
<span key={key++} className="text-[#79c0ff]">
|
|
331
|
+
{word}
|
|
332
|
+
</span>,
|
|
333
|
+
);
|
|
334
|
+
const afterWord = line.slice(i);
|
|
335
|
+
const eqIdx = afterWord.indexOf("=");
|
|
336
|
+
if (eqIdx > 0) {
|
|
337
|
+
tokens.push(<span key={key++}>{afterWord.slice(0, eqIdx)}</span>);
|
|
338
|
+
i += eqIdx;
|
|
339
|
+
}
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (KEYWORDS.has(word)) {
|
|
344
|
+
tokens.push(
|
|
345
|
+
<span key={key++} className="text-[#ff7b72]">
|
|
346
|
+
{word}
|
|
347
|
+
</span>,
|
|
348
|
+
);
|
|
349
|
+
} else if (word.length > 0 && word[0]! >= "A" && word[0]! <= "Z") {
|
|
350
|
+
tokens.push(
|
|
351
|
+
<span key={key++} className="text-[#d2a8ff]">
|
|
352
|
+
{word}
|
|
353
|
+
</span>,
|
|
354
|
+
);
|
|
355
|
+
} else {
|
|
356
|
+
tokens.push(<span key={key++}>{word}</span>);
|
|
357
|
+
}
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
tokens.push(<span key={key++}>{line[i]}</span>);
|
|
362
|
+
i++;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return tokens;
|
|
366
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Mail, MapPin, Send } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
export default function ContactPage() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="mx-auto max-w-4xl px-6 py-20">
|
|
6
|
+
<div className="mx-auto max-w-2xl text-center">
|
|
7
|
+
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">Contact</p>
|
|
8
|
+
<h1 className="mt-4 text-4xl font-bold tracking-tight sm:text-5xl">Get in touch</h1>
|
|
9
|
+
<p className="mt-4 text-lg text-muted-foreground">
|
|
10
|
+
Have a question or want to learn more? We'd love to hear from you.
|
|
11
|
+
</p>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div className="mt-16 grid gap-12 sm:grid-cols-5">
|
|
15
|
+
<div className="space-y-8 sm:col-span-2">
|
|
16
|
+
<div>
|
|
17
|
+
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
|
|
18
|
+
<Mail className="h-5 w-5" />
|
|
19
|
+
</div>
|
|
20
|
+
<h3 className="mt-4 text-sm font-semibold">Email</h3>
|
|
21
|
+
<p className="mt-1 text-sm text-muted-foreground">hello@x-framework.dev</p>
|
|
22
|
+
</div>
|
|
23
|
+
<div>
|
|
24
|
+
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
|
|
25
|
+
<MapPin className="h-5 w-5" />
|
|
26
|
+
</div>
|
|
27
|
+
<h3 className="mt-4 text-sm font-semibold">Location</h3>
|
|
28
|
+
<p className="mt-1 text-sm text-muted-foreground">San Francisco, CA</p>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<form className="space-y-5 sm:col-span-3" method="POST" action="/contact">
|
|
33
|
+
<div className="grid gap-5 sm:grid-cols-2">
|
|
34
|
+
<div>
|
|
35
|
+
<label htmlFor="name" className="block text-sm font-medium mb-2">
|
|
36
|
+
Name
|
|
37
|
+
</label>
|
|
38
|
+
<input
|
|
39
|
+
id="name"
|
|
40
|
+
name="name"
|
|
41
|
+
required
|
|
42
|
+
className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
43
|
+
placeholder="Your name"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
<div>
|
|
47
|
+
<label htmlFor="email" className="block text-sm font-medium mb-2">
|
|
48
|
+
Email
|
|
49
|
+
</label>
|
|
50
|
+
<input
|
|
51
|
+
id="email"
|
|
52
|
+
name="email"
|
|
53
|
+
type="email"
|
|
54
|
+
required
|
|
55
|
+
className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
56
|
+
placeholder="you@example.com"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
<div>
|
|
61
|
+
<label htmlFor="subject" className="block text-sm font-medium mb-2">
|
|
62
|
+
Subject
|
|
63
|
+
</label>
|
|
64
|
+
<input
|
|
65
|
+
id="subject"
|
|
66
|
+
name="subject"
|
|
67
|
+
required
|
|
68
|
+
className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
69
|
+
placeholder="How can we help?"
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
<div>
|
|
73
|
+
<label htmlFor="message" className="block text-sm font-medium mb-2">
|
|
74
|
+
Message
|
|
75
|
+
</label>
|
|
76
|
+
<textarea
|
|
77
|
+
id="message"
|
|
78
|
+
name="message"
|
|
79
|
+
rows={5}
|
|
80
|
+
required
|
|
81
|
+
className="w-full resize-none rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
82
|
+
placeholder="Tell us more..."
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
<button
|
|
86
|
+
type="submit"
|
|
87
|
+
className="inline-flex h-11 items-center gap-2 rounded-xl bg-primary px-6 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/25 transition-all hover:bg-primary/90"
|
|
88
|
+
>
|
|
89
|
+
Send message <Send className="h-4 w-4" />
|
|
90
|
+
</button>
|
|
91
|
+
</form>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Menu, X } from "lucide-react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
const sidebarLinks = [
|
|
5
|
+
{ href: "/docs", label: "Overview" },
|
|
6
|
+
{ href: "/docs/getting-started", label: "Getting Started" },
|
|
7
|
+
{ href: "/docs/routing", label: "Routing" },
|
|
8
|
+
{ href: "/docs/pages", label: "Pages & Loaders" },
|
|
9
|
+
{ href: "/docs/layouts", label: "Layouts" },
|
|
10
|
+
{ href: "/docs/api-routes", label: "API Routes" },
|
|
11
|
+
{ href: "/docs/server-functions", label: "Server Functions" },
|
|
12
|
+
{ href: "/docs/content-collections", label: "Content Collections" },
|
|
13
|
+
{ href: "/docs/middleware", label: "Middleware" },
|
|
14
|
+
{ href: "/docs/data-layer", label: "Data Layer" },
|
|
15
|
+
{ href: "/docs/build-deploy", label: "Build & Deploy" },
|
|
16
|
+
{ href: "/docs/configuration", label: "Configuration" },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export default function DocsLayout({ children }: { children: ReactNode }) {
|
|
20
|
+
return (
|
|
21
|
+
<div className="mx-auto flex min-h-[calc(100vh-4rem)] w-full max-w-6xl px-6">
|
|
22
|
+
<button
|
|
23
|
+
id="sidebar-btn"
|
|
24
|
+
type="button"
|
|
25
|
+
className="fixed left-4 top-20 z-50 flex h-8 w-8 items-center justify-center rounded-lg border border-border bg-background text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground lg:hidden"
|
|
26
|
+
aria-label="Toggle sidebar"
|
|
27
|
+
>
|
|
28
|
+
<Menu className="h-4 w-4 btn-icon-open" />
|
|
29
|
+
<X className="hidden h-4 w-4 btn-icon-close" />
|
|
30
|
+
</button>
|
|
31
|
+
|
|
32
|
+
<div id="sidebar-overlay" className="fixed inset-0 z-40 hidden bg-black/50 lg:hidden" />
|
|
33
|
+
|
|
34
|
+
<aside
|
|
35
|
+
id="sidebar-panel"
|
|
36
|
+
className="fixed left-0 top-16 z-50 hidden h-[calc(100vh-4rem)] w-56 overflow-y-auto border-r border-border/40 bg-background lg:hidden"
|
|
37
|
+
>
|
|
38
|
+
<nav className="px-4 pb-4 pt-0">
|
|
39
|
+
<p className="mb-3 pt-3 text-[10px] font-semibold uppercase tracking-[0.15em] text-muted-foreground">
|
|
40
|
+
Docs
|
|
41
|
+
</p>
|
|
42
|
+
<ul className="space-y-1">
|
|
43
|
+
{sidebarLinks.map((link) => (
|
|
44
|
+
<li key={link.href}>
|
|
45
|
+
<a
|
|
46
|
+
href={link.href}
|
|
47
|
+
className="block rounded-lg px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
|
48
|
+
>
|
|
49
|
+
{link.label}
|
|
50
|
+
</a>
|
|
51
|
+
</li>
|
|
52
|
+
))}
|
|
53
|
+
</ul>
|
|
54
|
+
</nav>
|
|
55
|
+
</aside>
|
|
56
|
+
|
|
57
|
+
<aside className="hidden w-56 shrink-0 border-r border-border/40 lg:block">
|
|
58
|
+
<nav className="sticky top-16 px-4 pb-4 pt-0">
|
|
59
|
+
<p className="mb-3 text-[10px] font-semibold uppercase tracking-[0.15em] text-muted-foreground">
|
|
60
|
+
Docs
|
|
61
|
+
</p>
|
|
62
|
+
<ul className="space-y-1">
|
|
63
|
+
{sidebarLinks.map((link) => (
|
|
64
|
+
<li key={link.href}>
|
|
65
|
+
<a
|
|
66
|
+
href={link.href}
|
|
67
|
+
className="block rounded-lg px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
|
68
|
+
>
|
|
69
|
+
{link.label}
|
|
70
|
+
</a>
|
|
71
|
+
</li>
|
|
72
|
+
))}
|
|
73
|
+
</ul>
|
|
74
|
+
</nav>
|
|
75
|
+
</aside>
|
|
76
|
+
<div className="min-w-0 flex-1">
|
|
77
|
+
<div className="mx-auto max-w-4xl px-6 py-12 sm:px-10">{children}</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<script
|
|
81
|
+
dangerouslySetInnerHTML={{
|
|
82
|
+
__html: `
|
|
83
|
+
(function(){
|
|
84
|
+
var btn=document.getElementById("sidebar-btn");
|
|
85
|
+
var panel=document.getElementById("sidebar-panel");
|
|
86
|
+
var overlay=document.getElementById("sidebar-overlay");
|
|
87
|
+
if(!btn||!panel||!overlay)return;
|
|
88
|
+
function close(){btn.classList.remove("open");panel.classList.add("hidden");overlay.classList.add("hidden")}
|
|
89
|
+
function openn(){btn.classList.add("open");panel.classList.remove("hidden");overlay.classList.remove("hidden")}
|
|
90
|
+
btn.addEventListener("click",function(){if(panel.classList.contains("hidden"))openn();else close()});
|
|
91
|
+
overlay.addEventListener("click",close);
|
|
92
|
+
panel.querySelectorAll("a").forEach(function(a){a.addEventListener("click",close)});
|
|
93
|
+
})();
|
|
94
|
+
`.trim(),
|
|
95
|
+
}}
|
|
96
|
+
/>
|
|
97
|
+
<style
|
|
98
|
+
dangerouslySetInnerHTML={{
|
|
99
|
+
__html: `
|
|
100
|
+
@media (max-width:1023px){
|
|
101
|
+
#sidebar-btn.open .btn-icon-open{display:none}
|
|
102
|
+
#sidebar-btn.open .btn-icon-close{display:block}
|
|
103
|
+
}
|
|
104
|
+
`.trim(),
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { RouteProps } from "@thexjs/core";
|
|
2
|
+
import { ArrowRight } from "lucide-react";
|
|
3
|
+
import { CodeBlock } from "../../components/code-block";
|
|
4
|
+
|
|
5
|
+
export default function DocPage({}: RouteProps) {
|
|
6
|
+
return (
|
|
7
|
+
<div>
|
|
8
|
+
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">API Routes</p>
|
|
9
|
+
<h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">API routes</h1>
|
|
10
|
+
<p className="mt-4 text-lg text-muted-foreground">
|
|
11
|
+
Build REST endpoints alongside your frontend pages. API routes live in{" "}
|
|
12
|
+
<span className="text-foreground">src/api/</span> and share the same process as your pages.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">File-based API routing</h2>
|
|
16
|
+
<p className="mt-3 text-muted-foreground">
|
|
17
|
+
Like pages, API routes use the file system. A file at{" "}
|
|
18
|
+
<span className="text-foreground">src/api/hello.ts</span> becomes{" "}
|
|
19
|
+
<span className="text-foreground">/api/hello</span>.
|
|
20
|
+
</p>
|
|
21
|
+
<CodeBlock
|
|
22
|
+
label="src/api/hello.ts"
|
|
23
|
+
code={`import type { ApiHandler } from "@thexjs/core";
|
|
24
|
+
|
|
25
|
+
export const GET: ApiHandler = ({ request }) => {
|
|
26
|
+
return Response.json({ message: "Hello from x!" });
|
|
27
|
+
};`}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">Request & response</h2>
|
|
31
|
+
<p className="mt-3 text-muted-foreground">
|
|
32
|
+
Each exported HTTP method receives the request and returns a standard{" "}
|
|
33
|
+
<span className="text-foreground">Response</span> object. Dynamic segments work the same as
|
|
34
|
+
pages: <span className="text-foreground">api/users/[id].ts</span> →{" "}
|
|
35
|
+
<span className="text-foreground">/api/users/:id</span>.
|
|
36
|
+
</p>
|
|
37
|
+
<CodeBlock
|
|
38
|
+
label="src/api/users.ts"
|
|
39
|
+
code={`import type { ApiHandler } from "@thexjs/core";
|
|
40
|
+
|
|
41
|
+
export const GET: ApiHandler = async ({ request }) => {
|
|
42
|
+
const users = await db.query("SELECT * FROM users");
|
|
43
|
+
return Response.json(users);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const POST: ApiHandler = async ({ request }) => {
|
|
47
|
+
const body = await request.json();
|
|
48
|
+
const result = await db.query(
|
|
49
|
+
"INSERT INTO users (name, email) VALUES (?, ?) RETURNING *",
|
|
50
|
+
[body.name, body.email]
|
|
51
|
+
);
|
|
52
|
+
return Response.json(result, { status: 201 });
|
|
53
|
+
};`}
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">POST endpoint example</h2>
|
|
57
|
+
<CodeBlock
|
|
58
|
+
label="src/api/contact.ts"
|
|
59
|
+
code={`import type { ApiHandler } from "@thexjs/core";
|
|
60
|
+
|
|
61
|
+
export const POST: ApiHandler = async ({ request }) => {
|
|
62
|
+
const form = await request.formData();
|
|
63
|
+
const email = form.get("email");
|
|
64
|
+
const message = form.get("message");
|
|
65
|
+
|
|
66
|
+
if (!email || !message) {
|
|
67
|
+
return Response.json(
|
|
68
|
+
{ error: "Email and message are required" },
|
|
69
|
+
{ status: 400 }
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
await sendEmail({ email, message });
|
|
74
|
+
return Response.json({ success: true });
|
|
75
|
+
};`}
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">API route tree</h2>
|
|
79
|
+
<p className="mt-3 text-muted-foreground">
|
|
80
|
+
API routes support the same file-tree conventions as pages — nested folders, dynamic
|
|
81
|
+
segments, and index files.
|
|
82
|
+
</p>
|
|
83
|
+
<CodeBlock
|
|
84
|
+
label="file tree"
|
|
85
|
+
lang="tree"
|
|
86
|
+
code={`src/api/
|
|
87
|
+
hello.ts -> GET /api/hello
|
|
88
|
+
users.ts -> GET, POST /api/users
|
|
89
|
+
users/
|
|
90
|
+
[id].ts -> GET, PUT, DELETE /api/users/:id
|
|
91
|
+
auth/
|
|
92
|
+
login.ts -> POST /api/auth/login
|
|
93
|
+
register.ts -> POST /api/auth/register`}
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
<h2 className="mt-12 text-xl font-bold tracking-tip">Process sharing</h2>
|
|
97
|
+
<p className="mt-3 text-muted-foreground">
|
|
98
|
+
API routes run in the same Bun process as your pages and server functions. This means you
|
|
99
|
+
can share database connections, in-memory caches, and configuration without any network
|
|
100
|
+
overhead.
|
|
101
|
+
</p>
|
|
102
|
+
|
|
103
|
+
<div className="mt-16 border-t border-border pt-8">
|
|
104
|
+
<a
|
|
105
|
+
href="/docs"
|
|
106
|
+
className="inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
107
|
+
>
|
|
108
|
+
<ArrowRight className="h-3.5 w-3.5 rotate-180" /> Back to docs
|
|
109
|
+
</a>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|