create-thexjs-app 0.1.2 → 0.1.4
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 +43 -20
- package/package.json +2 -7
- package/templates/basic/src/components/Link.tsx +6 -12
- package/templates/basic/src/lib/auth.ts +17 -6
- package/templates/basic/src/pages/login.tsx +11 -4
- package/templates/basic/src/pages/placeholder.tsx +11 -2
- package/templates/blog/src/pages/index.tsx +4 -1
- package/templates/default/src/pages/index.tsx +1 -1
- package/templates/landing/src/components/code-block.tsx +104 -10
- package/templates/landing/src/layouts/main.tsx +48 -18
- package/templates/landing/src/pages/docs/_layout.tsx +26 -14
- package/templates/landing/src/pages/docs/api-routes.tsx +1 -1
- package/templates/landing/src/pages/docs/build-deploy.tsx +1 -1
- package/templates/landing/src/pages/docs/configuration.tsx +1 -1
- package/templates/landing/src/pages/docs/content-collections.tsx +1 -1
- package/templates/landing/src/pages/docs/data-layer.tsx +3 -3
- package/templates/landing/src/pages/docs/getting-started.tsx +4 -4
- package/templates/landing/src/pages/docs/installation.tsx +16 -20
- package/templates/landing/src/pages/docs/introduction.tsx +8 -11
- package/templates/landing/src/pages/docs/layouts.tsx +1 -1
- package/templates/landing/src/pages/docs/middleware.tsx +1 -1
- package/templates/landing/src/pages/docs/packages/cli.tsx +10 -7
- package/templates/landing/src/pages/docs/packages/core.tsx +9 -5
- package/templates/landing/src/pages/docs/packages/env.tsx +3 -3
- package/templates/landing/src/pages/docs/pages.tsx +1 -1
- package/templates/landing/src/pages/docs/routing.tsx +1 -1
- package/templates/landing/src/pages/docs/server-functions.tsx +60 -6
- package/templates/landing/src/pages/features.tsx +1 -1
- package/templates/landing/src/pages/index.tsx +91 -126
- package/templates/landing/src/styles/globals.css +81 -45
- package/templates/landing/tsconfig.json +6 -1
- package/templates/saas/src/api/auth/login.ts +31 -0
- package/templates/saas/src/lib/auth.ts +27 -6
- package/templates/saas/src/pages/dashboard/settings.tsx +8 -2
- package/templates/saas/src/pages/login.tsx +83 -10
- package/templates/landing/src/pages/contact.tsx +0 -95
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { spawnSync } from "child_process";
|
|
5
|
-
import { existsSync, mkdirSync, readdirSync, writeFileSync
|
|
6
|
-
import { createInterface } from "readline/promises";
|
|
5
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, writeFileSync } from "fs";
|
|
7
6
|
import { dirname, join, resolve } from "path";
|
|
7
|
+
import { createInterface } from "readline/promises";
|
|
8
8
|
import { fileURLToPath } from "url";
|
|
9
9
|
|
|
10
10
|
// src/templates.ts
|
|
@@ -116,6 +116,35 @@ var TEMPLATES = {
|
|
|
116
116
|
};
|
|
117
117
|
var TEMPLATE_NAMES = Object.keys(TEMPLATES);
|
|
118
118
|
|
|
119
|
+
// src/terminal.ts
|
|
120
|
+
var reset = "\x1B[0m";
|
|
121
|
+
var muted = "\x1B[2m";
|
|
122
|
+
var bold = "\x1B[1m";
|
|
123
|
+
var amber = "\x1B[38;2;232;149;47m";
|
|
124
|
+
var cyan = "\x1B[38;2;61;214;198m";
|
|
125
|
+
var green = "\x1B[38;2;78;201;120m";
|
|
126
|
+
function banner() {
|
|
127
|
+
console.log("");
|
|
128
|
+
console.log(` ${amber}${bold}create-thexjs-app${reset}`);
|
|
129
|
+
console.log(` ${muted}Scaffold a new x project${reset}`);
|
|
130
|
+
console.log("");
|
|
131
|
+
}
|
|
132
|
+
function step(message) {
|
|
133
|
+
console.log(`${amber}\u2192${reset} ${message}`);
|
|
134
|
+
}
|
|
135
|
+
function success(message) {
|
|
136
|
+
console.log(`${green}\u2713${reset} ${message}`);
|
|
137
|
+
}
|
|
138
|
+
function command(cmd) {
|
|
139
|
+
console.log(` ${cyan}${cmd}${reset}`);
|
|
140
|
+
}
|
|
141
|
+
function dim(message) {
|
|
142
|
+
console.log(`${muted}${message}${reset}`);
|
|
143
|
+
}
|
|
144
|
+
function dimText(message) {
|
|
145
|
+
return `${muted}${message}${reset}`;
|
|
146
|
+
}
|
|
147
|
+
|
|
119
148
|
// src/index.ts
|
|
120
149
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
121
150
|
var TEMPLATES_ROOT = join(__dirname, "..", "templates");
|
|
@@ -146,15 +175,13 @@ async function prompt(question, fallback) {
|
|
|
146
175
|
return answer.trim() || fallback || "";
|
|
147
176
|
}
|
|
148
177
|
function printBanner() {
|
|
149
|
-
|
|
150
|
-
console.log(" create-thexjs-app");
|
|
151
|
-
console.log(" ------------------");
|
|
152
|
-
console.log("");
|
|
178
|
+
banner();
|
|
153
179
|
}
|
|
154
180
|
function printTemplateList() {
|
|
155
181
|
for (const name of TEMPLATE_NAMES) {
|
|
156
182
|
const meta = TEMPLATES[name];
|
|
157
|
-
|
|
183
|
+
if (!meta) continue;
|
|
184
|
+
const tag = meta.recommended ? dimText(" (recommended)") : "";
|
|
158
185
|
console.log(` ${name.padEnd(8)} ${meta.description}${tag}`);
|
|
159
186
|
}
|
|
160
187
|
}
|
|
@@ -179,10 +206,7 @@ async function main() {
|
|
|
179
206
|
console.log("\n Available templates:\n");
|
|
180
207
|
printTemplateList();
|
|
181
208
|
console.log("");
|
|
182
|
-
templateArg = await prompt(
|
|
183
|
-
`Choose a template (${TEMPLATE_NAMES.join("/")})`,
|
|
184
|
-
DEFAULT_TEMPLATE
|
|
185
|
-
);
|
|
209
|
+
templateArg = await prompt(`Choose a template (${TEMPLATE_NAMES.join("/")})`, DEFAULT_TEMPLATE);
|
|
186
210
|
}
|
|
187
211
|
if (!TEMPLATES[templateArg]) {
|
|
188
212
|
console.error(`
|
|
@@ -191,11 +215,10 @@ async function main() {
|
|
|
191
215
|
}
|
|
192
216
|
const meta = TEMPLATES[templateArg];
|
|
193
217
|
const templateDir = join(TEMPLATES_ROOT, templateArg);
|
|
194
|
-
|
|
195
|
-
[create-thexjs-app] Scaffolding "${slug}" from the "${templateArg}" template...`);
|
|
218
|
+
step(`Scaffolding "${slug}" from the "${templateArg}" template...`);
|
|
196
219
|
mkdirSync(targetDir, { recursive: true });
|
|
197
220
|
cpSync(templateDir, targetDir, { recursive: true });
|
|
198
|
-
|
|
221
|
+
step("Resolving latest @thexjs package versions...");
|
|
199
222
|
const coreVersion = await fetchLatestVersion("@thexjs/core") ?? FALLBACK_CORE_VERSION;
|
|
200
223
|
const cliVersion = await fetchLatestVersion("@thexjs/cli") ?? FALLBACK_CORE_VERSION;
|
|
201
224
|
const pkgJson = {
|
|
@@ -218,10 +241,10 @@ async function main() {
|
|
|
218
241
|
};
|
|
219
242
|
writeFileSync(join(targetDir, "package.json"), `${JSON.stringify(pkgJson, null, 2)}
|
|
220
243
|
`);
|
|
221
|
-
|
|
244
|
+
success(`Created ${slug}/`);
|
|
222
245
|
const hasBun = spawnSync("bun", ["--version"], { stdio: "ignore" }).status === 0;
|
|
223
246
|
if (hasBun) {
|
|
224
|
-
|
|
247
|
+
step("Installing dependencies with bun install...");
|
|
225
248
|
const result = spawnSync("bun", ["install"], { cwd: targetDir, stdio: "inherit" });
|
|
226
249
|
if (result.status !== 0) {
|
|
227
250
|
console.warn("[create-thexjs-app] bun install failed \u2014 you can retry manually.");
|
|
@@ -232,11 +255,11 @@ async function main() {
|
|
|
232
255
|
);
|
|
233
256
|
}
|
|
234
257
|
console.log("");
|
|
235
|
-
|
|
258
|
+
dim("Done! Next steps:");
|
|
236
259
|
console.log("");
|
|
237
|
-
|
|
238
|
-
if (!hasBun)
|
|
239
|
-
|
|
260
|
+
command(`cd ${slug}`);
|
|
261
|
+
if (!hasBun) command("bun install");
|
|
262
|
+
command("bun run dev");
|
|
240
263
|
console.log("");
|
|
241
264
|
}
|
|
242
265
|
main().catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-thexjs-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Scaffold a new x framework app (npm create thexjs-app@latest).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,12 +42,7 @@
|
|
|
42
42
|
"bin": {
|
|
43
43
|
"create-thexjs-app": "./dist/index.js"
|
|
44
44
|
},
|
|
45
|
-
"files": [
|
|
46
|
-
"dist",
|
|
47
|
-
"templates",
|
|
48
|
-
"README.md",
|
|
49
|
-
"LICENSE"
|
|
50
|
-
],
|
|
45
|
+
"files": ["dist", "templates", "README.md", "LICENSE"],
|
|
51
46
|
"publishConfig": {
|
|
52
47
|
"access": "public"
|
|
53
48
|
},
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
+
import { Link as XLink, type LinkProps as XLinkProps } from "@thexjs/core";
|
|
1
2
|
import type { ReactNode } from "react";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
href: string;
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
className?: string;
|
|
7
|
-
prefetch?: boolean;
|
|
8
|
-
}
|
|
4
|
+
type LinkProps = XLinkProps;
|
|
9
5
|
|
|
10
|
-
export default function Link(
|
|
11
|
-
return
|
|
12
|
-
<a href={href} className={className} data-no-nav={prefetch ? undefined : ""}>
|
|
13
|
-
{children}
|
|
14
|
-
</a>
|
|
15
|
-
);
|
|
6
|
+
export default function Link(props: LinkProps) {
|
|
7
|
+
return <XLink {...props} />;
|
|
16
8
|
}
|
|
9
|
+
|
|
10
|
+
export type { LinkProps };
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
// DEMO ONLY: hardcoded admin/admin credentials, plaintext password comparison,
|
|
3
|
+
// no session expiry. This auth is a placeholder for demos — replace with real
|
|
4
|
+
// credential storage (hashed passwords) before shipping anything production.
|
|
1
5
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
6
|
+
import { mkdirSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
|
|
4
9
|
|
|
5
10
|
const SESSION_COOKIE = "x_session";
|
|
6
11
|
const SESSION_MAX_AGE = 60 * 60 * 24 * 7;
|
|
@@ -12,9 +17,13 @@ export interface Session {
|
|
|
12
17
|
username: string;
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
let db: Database | null = null;
|
|
21
|
+
|
|
22
|
+
function getDb(): Database {
|
|
23
|
+
if (db) return db;
|
|
16
24
|
const dbPath = join(import.meta.dir, "..", "..", "data", "dev.db");
|
|
17
|
-
|
|
25
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
26
|
+
db = connectSQLite({ path: dbPath });
|
|
18
27
|
runSQLiteMigrations(db, join(import.meta.dir, "migrations"));
|
|
19
28
|
return db;
|
|
20
29
|
}
|
|
@@ -61,10 +70,12 @@ export function parseSessionCookie(cookieHeader: string | null): string | undefi
|
|
|
61
70
|
return undefined;
|
|
62
71
|
}
|
|
63
72
|
|
|
73
|
+
const SECURE_COOKIE_FLAG = process.env.NODE_ENV === "production" ? "; Secure" : "";
|
|
74
|
+
|
|
64
75
|
export function setSessionCookie(token: string): string {
|
|
65
|
-
return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}`;
|
|
76
|
+
return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}${SECURE_COOKIE_FLAG}`;
|
|
66
77
|
}
|
|
67
78
|
|
|
68
79
|
export function clearSessionCookie(): string {
|
|
69
|
-
return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0`;
|
|
80
|
+
return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0${SECURE_COOKIE_FLAG}`;
|
|
70
81
|
}
|
|
@@ -55,12 +55,16 @@ export default function LoginPage({ loaderData }: RouteProps) {
|
|
|
55
55
|
<h1 className="text-2xl font-bold text-center">Login</h1>
|
|
56
56
|
<form method="POST" action="/login" onSubmit={handleSubmit} className="space-y-4">
|
|
57
57
|
<div className="space-y-2">
|
|
58
|
-
<label className="text-sm font-medium">
|
|
59
|
-
|
|
58
|
+
<label htmlFor="username" className="text-sm font-medium">
|
|
59
|
+
Username
|
|
60
|
+
</label>
|
|
61
|
+
<Input id="username" name="username" defaultValue="admin" required />
|
|
60
62
|
</div>
|
|
61
63
|
<div className="space-y-2">
|
|
62
|
-
<label className="text-sm font-medium">
|
|
63
|
-
|
|
64
|
+
<label htmlFor="password" className="text-sm font-medium">
|
|
65
|
+
Password
|
|
66
|
+
</label>
|
|
67
|
+
<Input id="password" name="password" type="password" defaultValue="admin" required />
|
|
64
68
|
</div>
|
|
65
69
|
{error && (
|
|
66
70
|
<p id="login-error" className="text-sm text-destructive">
|
|
@@ -72,6 +76,9 @@ export default function LoginPage({ loaderData }: RouteProps) {
|
|
|
72
76
|
</Button>
|
|
73
77
|
</form>
|
|
74
78
|
<p className="text-xs text-muted-foreground text-center">Demo credentials: admin / admin</p>
|
|
79
|
+
<p className="text-xs text-muted-foreground text-center">
|
|
80
|
+
Demo only — replace with real auth before shipping.
|
|
81
|
+
</p>
|
|
75
82
|
<p className="text-center">
|
|
76
83
|
<a
|
|
77
84
|
href="/"
|
|
@@ -5,7 +5,8 @@ export default function PlaceholderPage() {
|
|
|
5
5
|
{"{"}JSON{"}"} Placeholder
|
|
6
6
|
</h1>
|
|
7
7
|
<p className="text-muted-foreground">
|
|
8
|
-
Free fake API powered by <strong>@thexjs/core</strong> — in-memory data, sub-ms response
|
|
8
|
+
Free fake API powered by <strong>@thexjs/core</strong> — in-memory data, sub-ms response
|
|
9
|
+
times.
|
|
9
10
|
</p>
|
|
10
11
|
|
|
11
12
|
<div className="overflow-x-auto rounded-lg border border-border">
|
|
@@ -25,6 +26,7 @@ export default function PlaceholderPage() {
|
|
|
25
26
|
<td className="text-right p-3">100</td>
|
|
26
27
|
<td className="text-right p-3">
|
|
27
28
|
<button
|
|
29
|
+
type="button"
|
|
28
30
|
className="fetch-btn text-primary hover:underline text-xs"
|
|
29
31
|
data-url="/api/placeholder/posts"
|
|
30
32
|
>
|
|
@@ -41,6 +43,7 @@ export default function PlaceholderPage() {
|
|
|
41
43
|
<td className="text-right p-3">500</td>
|
|
42
44
|
<td className="text-right p-3">
|
|
43
45
|
<button
|
|
46
|
+
type="button"
|
|
44
47
|
className="fetch-btn text-primary hover:underline text-xs"
|
|
45
48
|
data-url="/api/placeholder/comments"
|
|
46
49
|
>
|
|
@@ -55,6 +58,7 @@ export default function PlaceholderPage() {
|
|
|
55
58
|
<td className="text-right p-3">200</td>
|
|
56
59
|
<td className="text-right p-3">
|
|
57
60
|
<button
|
|
61
|
+
type="button"
|
|
58
62
|
className="fetch-btn text-primary hover:underline text-xs"
|
|
59
63
|
data-url="/api/placeholder/todos"
|
|
60
64
|
>
|
|
@@ -69,6 +73,7 @@ export default function PlaceholderPage() {
|
|
|
69
73
|
<td className="text-right p-3">10</td>
|
|
70
74
|
<td className="text-right p-3">
|
|
71
75
|
<button
|
|
76
|
+
type="button"
|
|
72
77
|
className="fetch-btn text-primary hover:underline text-xs"
|
|
73
78
|
data-url="/api/placeholder/users"
|
|
74
79
|
>
|
|
@@ -81,7 +86,11 @@ export default function PlaceholderPage() {
|
|
|
81
86
|
All endpoints (sequential)
|
|
82
87
|
</td>
|
|
83
88
|
<td className="text-right p-3">
|
|
84
|
-
<button
|
|
89
|
+
<button
|
|
90
|
+
id="fetch-all"
|
|
91
|
+
type="button"
|
|
92
|
+
className="fetch-btn text-primary hover:underline text-xs"
|
|
93
|
+
>
|
|
85
94
|
Fetch All
|
|
86
95
|
</button>
|
|
87
96
|
</td>
|
|
@@ -59,7 +59,10 @@ export default function HomePage() {
|
|
|
59
59
|
placeholder="Enter your email"
|
|
60
60
|
className="flex-1 rounded-lg border border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
61
61
|
/>
|
|
62
|
-
<button
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
className="rounded-lg bg-primary px-6 py-2.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
|
|
65
|
+
>
|
|
63
66
|
Subscribe
|
|
64
67
|
</button>
|
|
65
68
|
</div>
|
|
@@ -2,7 +2,7 @@ import type { RouteProps } from "@thexjs/core";
|
|
|
2
2
|
|
|
3
3
|
export const mode = "static";
|
|
4
4
|
|
|
5
|
-
export default function HomePage(
|
|
5
|
+
export default function HomePage(_props: RouteProps) {
|
|
6
6
|
return (
|
|
7
7
|
<div className="flex flex-1 flex-col items-center justify-center px-6 pb-20 pt-8 sm:px-10">
|
|
8
8
|
<div className="mb-10 flex w-full max-w-md items-center gap-3 rounded-xl border border-border bg-surface/80 px-4 py-3 font-mono text-xs backdrop-blur-sm sm:text-sm">
|
|
@@ -5,20 +5,114 @@ interface CodeBlockProps {
|
|
|
5
5
|
label: string;
|
|
6
6
|
code: string;
|
|
7
7
|
lang?: string;
|
|
8
|
+
/** Terminal-style output with prompt prefixes and scanline texture. */
|
|
9
|
+
variant?: "code" | "terminal";
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
function TerminalBody({ code, lang }: { code: string; lang: string }) {
|
|
13
|
+
const lines = code.split("\n");
|
|
14
|
+
|
|
11
15
|
return (
|
|
12
|
-
<div className="
|
|
13
|
-
<div
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
<div className="relative font-mono text-[13px] leading-[1.65]">
|
|
17
|
+
<div
|
|
18
|
+
className="pointer-events-none absolute inset-0 opacity-[0.04]"
|
|
19
|
+
style={{
|
|
20
|
+
backgroundImage:
|
|
21
|
+
"repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.15) 2px, rgba(255,255,255,0.15) 4px)",
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
<pre className="relative overflow-x-auto p-5">
|
|
25
|
+
{lines.map((line, i) => {
|
|
26
|
+
const isPrompt = line.startsWith("$") || line.startsWith(">");
|
|
27
|
+
const isOutput = line.startsWith(" ") && !line.startsWith(" ");
|
|
28
|
+
const isDim = line.trim() === "" || line.includes("(recommended)");
|
|
29
|
+
|
|
30
|
+
if (lang === "bash" && isPrompt) {
|
|
31
|
+
const [, ...rest] = line.split(/(?<=\$|\>)\s?/);
|
|
32
|
+
const cmd = rest.join("") || line.slice(1).trim();
|
|
33
|
+
return (
|
|
34
|
+
<div key={`${i}-${line.slice(0, 8)}`} className="flex gap-3">
|
|
35
|
+
<span className="shrink-0 select-none text-[var(--terminal-prompt)]">
|
|
36
|
+
{line.startsWith("$") ? "$" : ">"}
|
|
37
|
+
</span>
|
|
38
|
+
<code className="text-[var(--terminal-text)]">{cmd}</code>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (isOutput) {
|
|
44
|
+
return (
|
|
45
|
+
<div key={`${i}-${line.slice(0, 8)}`} className="pl-5 text-[var(--terminal-muted)]">
|
|
46
|
+
{line.trimStart()}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
key={`${i}-${line.slice(0, 8)}`}
|
|
54
|
+
className={isDim ? "text-[var(--terminal-muted)]/80" : "text-[var(--terminal-text)]"}
|
|
55
|
+
>
|
|
56
|
+
{lang === "bash" ? line : highlight(line, lang)}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
})}
|
|
21
60
|
</pre>
|
|
22
61
|
</div>
|
|
23
62
|
);
|
|
24
63
|
}
|
|
64
|
+
|
|
65
|
+
export function CodeBlock({ label, code, lang = "tsx", variant = "code" }: CodeBlockProps) {
|
|
66
|
+
const isTerminal = variant === "terminal" || lang === "bash" || lang === "tree";
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
className={`code-block mt-6 overflow-hidden rounded-2xl border shadow-2xl ${
|
|
71
|
+
isTerminal
|
|
72
|
+
? "border-[var(--terminal-border)] bg-[var(--terminal-bg)] shadow-[var(--terminal-glow)]"
|
|
73
|
+
: "border-border/50 bg-[#0a0e14] shadow-black/40"
|
|
74
|
+
}`}
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
className={`flex items-center justify-between gap-3 border-b px-4 py-2.5 ${
|
|
78
|
+
isTerminal
|
|
79
|
+
? "border-[var(--terminal-border)] bg-[var(--terminal-bar)]"
|
|
80
|
+
: "border-white/[0.06] bg-[#121820]"
|
|
81
|
+
}`}
|
|
82
|
+
>
|
|
83
|
+
<div className="flex items-center gap-1.5">
|
|
84
|
+
<span className="h-2.5 w-2.5 rounded-full bg-[#ff5f56]" />
|
|
85
|
+
<span className="h-2.5 w-2.5 rounded-full bg-[#ffbd2e]" />
|
|
86
|
+
<span className="h-2.5 w-2.5 rounded-full bg-[#27c93f]" />
|
|
87
|
+
</div>
|
|
88
|
+
<span
|
|
89
|
+
className={`truncate font-mono text-[11px] tracking-wide ${
|
|
90
|
+
isTerminal ? "text-[var(--terminal-label)]" : "text-[#7d8da6]"
|
|
91
|
+
}`}
|
|
92
|
+
>
|
|
93
|
+
{label}
|
|
94
|
+
</span>
|
|
95
|
+
<span className="hidden w-12 sm:block" />
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
{isTerminal ? (
|
|
99
|
+
<TerminalBody code={code} lang={lang} />
|
|
100
|
+
) : (
|
|
101
|
+
<pre className="overflow-x-auto p-5 text-sm leading-relaxed">
|
|
102
|
+
<code className="font-mono text-[#e8edf5]">{highlight(code, lang)}</code>
|
|
103
|
+
</pre>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Shorthand for bash/CLI snippets. */
|
|
110
|
+
export function TerminalBlock({
|
|
111
|
+
label,
|
|
112
|
+
code,
|
|
113
|
+
}: {
|
|
114
|
+
label: string;
|
|
115
|
+
code: string;
|
|
116
|
+
}): ReactNode {
|
|
117
|
+
return <CodeBlock label={label} code={code} lang="bash" variant="terminal" />;
|
|
118
|
+
}
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
|
|
3
|
+
function LogoMark() {
|
|
4
|
+
return (
|
|
5
|
+
<svg viewBox="0 0 24 24" className="h-5 w-5" fill="none" aria-hidden="true">
|
|
6
|
+
<title>x logo</title>
|
|
7
|
+
<polygon points="3,5 5,3 21,19 19,21" fill="currentColor" />
|
|
8
|
+
<polygon points="19,5 21,3 5,21 3,19" fill="currentColor" opacity="0.45" />
|
|
9
|
+
</svg>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
4
14
|
return (
|
|
5
15
|
<div className="flex min-h-screen flex-col bg-background">
|
|
6
|
-
<header className="fixed top-0 z-[99] w-full border-b border-border/
|
|
7
|
-
<div className="mx-auto flex h-
|
|
16
|
+
<header className="fixed top-0 z-[99] w-full border-b border-border/50 bg-background/70 backdrop-blur-xl">
|
|
17
|
+
<div className="mx-auto flex h-14 max-w-6xl items-center justify-between px-6">
|
|
8
18
|
<a
|
|
9
19
|
href="/"
|
|
10
|
-
className="flex items-center text-primary transition-
|
|
20
|
+
className="group flex items-center gap-2.5 text-primary transition-opacity hover:opacity-90"
|
|
11
21
|
aria-label="x home"
|
|
12
22
|
>
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
<span className="flex h-8 w-8 items-center justify-center rounded-lg border border-border bg-card">
|
|
24
|
+
<LogoMark />
|
|
25
|
+
</span>
|
|
26
|
+
<span className="font-display text-sm font-bold tracking-tight text-foreground/90">
|
|
27
|
+
x
|
|
28
|
+
</span>
|
|
17
29
|
</a>
|
|
18
|
-
<nav className="flex items-center gap-
|
|
30
|
+
<nav className="flex items-center gap-6 text-sm font-medium text-muted-foreground">
|
|
19
31
|
<a href="/docs" className="transition-colors hover:text-foreground">
|
|
20
32
|
Docs
|
|
21
33
|
</a>
|
|
@@ -26,21 +38,39 @@ export default function RootLayout({ children }: { children: ReactNode }) {
|
|
|
26
38
|
href="https://github.com/abdelkabirouadoukou/x"
|
|
27
39
|
target="_blank"
|
|
28
40
|
rel="noopener noreferrer"
|
|
29
|
-
className="
|
|
30
|
-
aria-label="GitHub repository"
|
|
41
|
+
className="hidden items-center gap-1.5 transition-colors hover:text-foreground sm:flex"
|
|
31
42
|
>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
GitHub
|
|
44
|
+
</a>
|
|
45
|
+
<a
|
|
46
|
+
href="/docs/installation"
|
|
47
|
+
className="inline-flex h-8 items-center rounded-lg bg-primary px-3.5 text-xs font-semibold text-primary-foreground transition-colors hover:bg-primary/90"
|
|
48
|
+
>
|
|
49
|
+
Install
|
|
36
50
|
</a>
|
|
37
51
|
</nav>
|
|
38
52
|
</div>
|
|
39
53
|
</header>
|
|
40
|
-
<main className="flex-1 pt-
|
|
41
|
-
<footer className="border-t border-border/
|
|
42
|
-
<div className="mx-auto max-w-6xl px-6 py-
|
|
43
|
-
<
|
|
54
|
+
<main className="flex-1 pt-14">{children}</main>
|
|
55
|
+
<footer className="border-t border-border/50">
|
|
56
|
+
<div className="mx-auto flex max-w-6xl flex-col items-center justify-between gap-3 px-6 py-10 text-sm text-muted-foreground sm:flex-row">
|
|
57
|
+
<p>
|
|
58
|
+
<span className="font-display font-bold text-foreground">x</span> — fullstack framework
|
|
59
|
+
for Bun
|
|
60
|
+
</p>
|
|
61
|
+
<div className="flex gap-5">
|
|
62
|
+
<a href="/docs" className="transition-colors hover:text-foreground">
|
|
63
|
+
Documentation
|
|
64
|
+
</a>
|
|
65
|
+
<a
|
|
66
|
+
href="https://github.com/abdelkabirouadoukou/x"
|
|
67
|
+
target="_blank"
|
|
68
|
+
rel="noopener noreferrer"
|
|
69
|
+
className="transition-colors hover:text-foreground"
|
|
70
|
+
>
|
|
71
|
+
GitHub
|
|
72
|
+
</a>
|
|
73
|
+
</div>
|
|
44
74
|
</div>
|
|
45
75
|
</footer>
|
|
46
76
|
</div>
|
|
@@ -17,6 +17,7 @@ const sidebarSections = [
|
|
|
17
17
|
{ href: "/docs/packages/core", label: "@thexjs/core" },
|
|
18
18
|
{ href: "/docs/packages/cli", label: "@thexjs/cli" },
|
|
19
19
|
{ href: "/docs/packages/env", label: "@thexjs/env" },
|
|
20
|
+
{ href: "/docs/packages/adapter-vercel", label: "@thexjs/adapter-vercel" },
|
|
20
21
|
],
|
|
21
22
|
},
|
|
22
23
|
{
|
|
@@ -32,6 +33,8 @@ const sidebarSections = [
|
|
|
32
33
|
{ href: "/docs/data-layer", label: "Data Layer" },
|
|
33
34
|
{ href: "/docs/build-deploy", label: "Build & Deploy" },
|
|
34
35
|
{ href: "/docs/configuration", label: "Configuration" },
|
|
36
|
+
{ href: "/docs/security", label: "Security" },
|
|
37
|
+
{ href: "/docs/observability", label: "Observability" },
|
|
35
38
|
],
|
|
36
39
|
},
|
|
37
40
|
];
|
|
@@ -40,16 +43,17 @@ function SidebarNav() {
|
|
|
40
43
|
return (
|
|
41
44
|
<>
|
|
42
45
|
{sidebarSections.map((section) => (
|
|
43
|
-
<div key={section.title} className="mb-
|
|
44
|
-
<p className="mb-
|
|
46
|
+
<div key={section.title} className="mb-7 last:mb-0">
|
|
47
|
+
<p className="mb-2 font-mono text-[10px] uppercase tracking-[0.18em] text-primary/80">
|
|
45
48
|
{section.title}
|
|
46
49
|
</p>
|
|
47
|
-
<ul className="space-y-
|
|
50
|
+
<ul className="space-y-0.5">
|
|
48
51
|
{section.links.map((link) => (
|
|
49
52
|
<li key={link.href}>
|
|
50
53
|
<a
|
|
51
54
|
href={link.href}
|
|
52
|
-
|
|
55
|
+
data-doc-link={link.href}
|
|
56
|
+
className="doc-nav-link block rounded-lg border border-transparent px-3 py-2 text-[13px] text-muted-foreground transition-colors hover:border-border/60 hover:bg-muted/50 hover:text-foreground"
|
|
53
57
|
>
|
|
54
58
|
{link.label}
|
|
55
59
|
</a>
|
|
@@ -64,41 +68,49 @@ function SidebarNav() {
|
|
|
64
68
|
|
|
65
69
|
export default function DocsLayout({ children }: { children: ReactNode }) {
|
|
66
70
|
return (
|
|
67
|
-
<div className="mx-auto flex min-h-[calc(100vh-
|
|
71
|
+
<div className="mx-auto flex min-h-[calc(100vh-3.5rem)] w-full max-w-6xl px-4 sm:px-6">
|
|
68
72
|
<button
|
|
69
73
|
id="sidebar-btn"
|
|
70
74
|
type="button"
|
|
71
|
-
className="fixed left-4 top-
|
|
75
|
+
className="fixed left-4 top-[4.25rem] 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"
|
|
72
76
|
aria-label="Toggle sidebar"
|
|
73
77
|
>
|
|
74
78
|
<Menu className="h-4 w-4 btn-icon-open" />
|
|
75
79
|
<X className="hidden h-4 w-4 btn-icon-close" />
|
|
76
80
|
</button>
|
|
77
81
|
|
|
78
|
-
<div id="sidebar-overlay" className="fixed inset-0 z-40 hidden bg-black/
|
|
82
|
+
<div id="sidebar-overlay" className="fixed inset-0 z-40 hidden bg-black/60 lg:hidden" />
|
|
79
83
|
|
|
80
84
|
<aside
|
|
81
85
|
id="sidebar-panel"
|
|
82
|
-
className="fixed left-0 top-
|
|
86
|
+
className="fixed left-0 top-14 z-50 hidden h-[calc(100vh-3.5rem)] w-60 overflow-y-auto border-r border-border/50 bg-background lg:hidden"
|
|
83
87
|
>
|
|
84
|
-
<nav className="px-
|
|
88
|
+
<nav className="px-3 pb-6 pt-4">
|
|
85
89
|
<SidebarNav />
|
|
86
90
|
</nav>
|
|
87
91
|
</aside>
|
|
88
92
|
|
|
89
|
-
<aside className="hidden w-
|
|
90
|
-
<nav className="sticky top-
|
|
93
|
+
<aside className="hidden w-60 shrink-0 border-r border-border/50 lg:block">
|
|
94
|
+
<nav className="sticky top-14 max-h-[calc(100vh-3.5rem)] overflow-y-auto px-3 pb-8 pt-2">
|
|
91
95
|
<SidebarNav />
|
|
92
96
|
</nav>
|
|
93
97
|
</aside>
|
|
98
|
+
|
|
94
99
|
<div className="min-w-0 flex-1">
|
|
95
|
-
<div className="mx-auto max-w-
|
|
100
|
+
<div className="doc-content mx-auto max-w-3xl px-4 py-10 sm:px-8 sm:py-12">{children}</div>
|
|
96
101
|
</div>
|
|
97
102
|
|
|
98
103
|
<script
|
|
99
104
|
dangerouslySetInnerHTML={{
|
|
100
105
|
__html: `
|
|
101
106
|
(function(){
|
|
107
|
+
var path=location.pathname.replace(/\\/$/,"")||"/docs";
|
|
108
|
+
document.querySelectorAll("[data-doc-link]").forEach(function(a){
|
|
109
|
+
var href=a.getAttribute("data-doc-link").replace(/\\/$/,"")||"/docs";
|
|
110
|
+
if(href===path||(path!=="/docs"&&href!=="/docs"&&path.indexOf(href)===0)){
|
|
111
|
+
a.classList.add("border-primary/30","bg-primary/10","text-primary");
|
|
112
|
+
}
|
|
113
|
+
});
|
|
102
114
|
var btn=document.getElementById("sidebar-btn");
|
|
103
115
|
var panel=document.getElementById("sidebar-panel");
|
|
104
116
|
var overlay=document.getElementById("sidebar-overlay");
|
|
@@ -109,7 +121,7 @@ export default function DocsLayout({ children }: { children: ReactNode }) {
|
|
|
109
121
|
overlay.addEventListener("click",close);
|
|
110
122
|
panel.querySelectorAll("a").forEach(function(a){a.addEventListener("click",close)});
|
|
111
123
|
})();
|
|
112
|
-
|
|
124
|
+
`.trim(),
|
|
113
125
|
}}
|
|
114
126
|
/>
|
|
115
127
|
<style
|
|
@@ -119,7 +131,7 @@ export default function DocsLayout({ children }: { children: ReactNode }) {
|
|
|
119
131
|
#sidebar-btn.open .btn-icon-open{display:none}
|
|
120
132
|
#sidebar-btn.open .btn-icon-close{display:block}
|
|
121
133
|
}
|
|
122
|
-
|
|
134
|
+
`.trim(),
|
|
123
135
|
}}
|
|
124
136
|
/>
|
|
125
137
|
</div>
|