Skip to content

Commit 444c8b1

Browse files
Copilothuangyiirene
andcommitted
Add i18n configuration and restructure app for multilingual support
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 1286a8c commit 444c8b1

11 files changed

Lines changed: 297 additions & 228 deletions

File tree

apps/docs/app/docs/[[...slug]]/page.tsx renamed to apps/docs/app/[lang]/docs/[[...slug]]/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ const components = {
1717
};
1818

1919
export default async function Page(props: {
20-
params: Promise<{ slug?: string[] }>;
20+
params: Promise<{ lang: string; slug?: string[] }>;
2121
}) {
2222
const params = await props.params;
23-
const page = await source.getPage(params.slug ?? []);
23+
const page = source.getPage(params.slug ?? [], params.lang);
2424
if (!page) notFound();
2525

2626
const data = page.data as any;
@@ -46,10 +46,10 @@ export async function generateStaticParams() {
4646
}
4747

4848
export async function generateMetadata(props: {
49-
params: Promise<{ slug?: string[] }>;
49+
params: Promise<{ lang: string; slug?: string[] }>;
5050
}): Promise<Metadata> {
5151
const params = await props.params;
52-
const page = await source.getPage(params.slug ?? []);
52+
const page = source.getPage(params.slug ?? [], params.lang);
5353
if (!page) notFound();
5454

5555
return {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { source } from '@/app/source';
2+
import type { Metadata } from 'next';
3+
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
4+
import type { ReactNode } from 'react';
5+
import { baseOptions } from '@/app/layout.config';
6+
7+
export default async function Layout({
8+
params,
9+
children,
10+
}: {
11+
params: Promise<{ lang: string }>;
12+
children: ReactNode;
13+
}) {
14+
const { lang } = await params;
15+
16+
return (
17+
<DocsLayout tree={source.pageTree[lang]} {...baseOptions}>
18+
{children}
19+
</DocsLayout>
20+
);
21+
}

apps/docs/app/[lang]/layout.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { ReactNode } from 'react';
2+
import { RootProvider } from 'fumadocs-ui/provider/next';
3+
import { i18n } from '@/lib/i18n';
4+
5+
export default async function LanguageLayout({
6+
params,
7+
children,
8+
}: {
9+
params: Promise<{ lang: string }>;
10+
children: ReactNode;
11+
}) {
12+
const { lang } = await params;
13+
14+
return (
15+
<html lang={lang} suppressHydrationWarning>
16+
<body>
17+
<RootProvider>{children}</RootProvider>
18+
</body>
19+
</html>
20+
);
21+
}
22+
23+
export async function generateStaticParams() {
24+
return i18n.languages.map((lang) => ({ lang }));
25+
}

apps/docs/app/[lang]/page.tsx

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
import Link from 'next/link';
2+
import { Database, FileJson, Layers, ShieldCheck, Zap, Globe, Cpu, LayoutTemplate, Bot } from 'lucide-react';
3+
import { HomeLayout } from 'fumadocs-ui/layouts/home';
4+
import { baseOptions } from '@/app/layout.config';
5+
6+
export default function HomePage() {
7+
return (
8+
<HomeLayout {...baseOptions}>
9+
<main className="flex min-h-screen flex-col items-center justify-center text-center px-4 py-16 sm:py-24 md:py-32 overflow-hidden bg-background text-foreground selection:bg-primary/20">
10+
11+
{/* Hero Section */}
12+
<div className="relative z-10 max-w-5xl space-y-8">
13+
<div className="inline-flex items-center rounded-full border border-fd-primary/20 bg-fd-primary/5 px-3 py-1 text-sm text-fd-primary backdrop-blur-sm transition-colors hover:bg-fd-primary/10 hover:border-fd-primary/30">
14+
<span className="flex h-2 w-2 rounded-full bg-fd-primary mr-2 animate-pulse"></span>
15+
Protocol Specification v1.0
16+
</div>
17+
18+
<h1 className="text-5xl font-extrabold tracking-tight sm:text-7xl md:text-8xl bg-gradient-to-br from-foreground via-foreground/90 to-fd-primary/60 bg-clip-text text-transparent pb-4">
19+
The ObjectStack <br/> Protocol
20+
</h1>
21+
22+
<p className="mx-auto max-w-2xl text-lg text-fd-muted-foreground sm:text-xl leading-relaxed">
23+
The Open Standard for Metadata-Driven Enterprise Software.
24+
<br className="hidden sm:inline" />
25+
<span className="text-fd-foreground font-medium">Validatable. Database-Agnostic. AI-Native.</span>
26+
</p>
27+
28+
<div className="flex flex-col sm:flex-row items-center justify-center gap-4 pt-4">
29+
<Link
30+
href="/docs/guides/getting-started"
31+
className="inline-flex h-12 items-center justify-center rounded-lg bg-fd-primary px-8 text-sm font-medium text-fd-primary-foreground shadow-lg shadow-fd-primary/20 transition-all hover:bg-fd-primary/90 hover:scale-105 hover:shadow-fd-primary/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring disabled:pointer-events-none disabled:opacity-50"
32+
>
33+
Start Building
34+
</Link>
35+
<Link
36+
href="/docs"
37+
className="inline-flex h-12 items-center justify-center rounded-lg border border-fd-border bg-fd-card/50 px-8 text-sm font-medium shadow-sm transition-all hover:bg-fd-accent hover:text-fd-accent-foreground backdrop-blur-sm hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring disabled:pointer-events-none disabled:opacity-50"
38+
>
39+
Read Specification
40+
</Link>
41+
</div>
42+
43+
{/* Code Preview Decorator */}
44+
<div className="relative mx-auto mt-12 w-full max-w-3xl transform rounded-xlbg-gradient-to-br from-fd-border/50 to-fd-border/10 p-2 opacity-90 transition-all hover:scale-[1.01] hover:opacity-100 sm:mt-16">
45+
<div className="overflow-hidden rounded-xl border border-fd-border bg-fd-card shadow-2xl">
46+
<div className="flex items-center gap-2 border-b border-fd-border bg-fd-muted/50 px-4 py-3">
47+
<div className="h-3 w-3 rounded-full bg-red-500/80" />
48+
<div className="h-3 w-3 rounded-full bg-yellow-500/80" />
49+
<div className="h-3 w-3 rounded-full bg-green-500/80" />
50+
<div className="ml-2 text-xs font-medium text-fd-muted-foreground font-mono">
51+
contract.zod.ts
52+
</div>
53+
</div>
54+
<div className="overflow-x-auto p-6 text-left">
55+
<pre className="font-mono text-sm leading-6">
56+
<span className="text-purple-400">import</span> <span className="text-fd-foreground">{'{'}</span> <span className="text-yellow-300">ObjectProtocol</span> <span className="text-fd-foreground">{'}'}</span> <span className="text-purple-400">from</span> <span className="text-green-300">'@objectstack/spec'</span>;<br/><br/>
57+
<span className="text-purple-400">export const</span> <span className="text-blue-300">Issue</span> <span className="text-purple-400">=</span> <span className="text-yellow-300">ObjectProtocol</span>.<span className="text-blue-300">define</span>(<span className="text-fd-foreground">{'{'}</span><br/>
58+
&nbsp;&nbsp;code: <span className="text-green-300">'issue_tracker'</span>,<br/>
59+
&nbsp;&nbsp;fields: <span className="text-fd-foreground">{'{'}</span><br/>
60+
&nbsp;&nbsp;&nbsp;&nbsp;summary: <span className="text-yellow-300">Field</span>.<span className="text-blue-300">text</span>(<span className="text-fd-foreground">{'{'}</span> required: <span className="text-red-300">true</span> <span className="text-fd-foreground">{'}'}</span>),<br/>
61+
&nbsp;&nbsp;&nbsp;&nbsp;priority: <span className="text-yellow-300">Field</span>.<span className="text-blue-300">select</span>([<span className="text-green-300">'P0'</span>, <span className="text-green-300">'P1'</span>, <span className="text-green-300">'P2'</span>]),<br/>
62+
&nbsp;&nbsp;&nbsp;&nbsp;assignee: <span className="text-yellow-300">Field</span>.<span className="text-blue-300">lookup</span>(<span className="text-green-300">'users'</span>)<br/>
63+
&nbsp;&nbsp;<span className="text-fd-foreground">{'}'}</span>,<br/>
64+
&nbsp;&nbsp;policy: <span className="text-fd-foreground">{'{'}</span> <span className="text-blue-300">audit</span>: <span className="text-red-300">true</span>, <span className="text-blue-300">api_access</span>: <span className="text-green-300">'public'</span> <span className="text-fd-foreground">{'}'}</span><br/>
65+
<span className="text-fd-foreground">{'}'}</span>);
66+
</pre>
67+
</div>
68+
</div>
69+
{/* Glow Effect behind Code */}
70+
<div className="absolute -inset-4 -z-10 bg-fd-primary/20 blur-3xl opacity-30 rounded-[50%]" />
71+
</div>
72+
</div>
73+
74+
{/* Grid Pattern Background */}
75+
<div className="absolute inset-0 -z-10 h-full w-full bg-[linear-gradient(to_right,#8080800a_1px,transparent_1px),linear-gradient(to_bottom,#8080800a_1px,transparent_1px)] bg-[size:4rem_4rem] [mask-image:radial-gradient(ellipse_60%_50%_at_50%_50%,#000_70%,transparent_100%)] pointer-events-none" />
76+
77+
{/* Feature Grid */}
78+
<div className="mt-24 grid grid-cols-1 gap-8 text-left sm:grid-cols-2 lg:grid-cols-3 max-w-6xl w-full">
79+
<FeatureCard
80+
icon={<Database className="h-6 w-6" />}
81+
title="ObjectQL Data Layer"
82+
href="/docs/specifications/data/architecture"
83+
description="Strict JSON schemas for entities, fields, and relationships. It is the SQL you can send over the wire."
84+
/>
85+
<FeatureCard
86+
icon={<Layers className="h-6 w-6" />}
87+
title="ObjectUI View Layer"
88+
href="/docs/specifications/ui/sdui-protocol"
89+
description="Server-Driven UI protocol defining forms, grids, and dashboards. Decouples logic from the frontend implementation."
90+
/>
91+
<FeatureCard
92+
icon={<Zap className="h-6 w-6" />}
93+
title="ObjectOS Kernel"
94+
href="/docs/specifications/server/kernel-architecture"
95+
description="The runtime contract for permissions, workflows, and automation. Stateless business logic execution."
96+
/>
97+
<FeatureCard
98+
icon={<ShieldCheck className="h-6 w-6" />}
99+
title="Zero-Trust Security"
100+
href="/docs/specifications/server/permission-governance"
101+
description="Policy-as-Code. ACLs and Field Level Security are compiled into the database query engine."
102+
/>
103+
<FeatureCard
104+
icon={<FileJson className="h-6 w-6" />}
105+
title="Zod-First Definition"
106+
href="/docs/specifications/data/schema-definition"
107+
description="The entire protocol is defined in Zod. Runtime validation and static type inference come for free."
108+
/>
109+
<FeatureCard
110+
icon={<Globe className="h-6 w-6" />}
111+
title="Universal Backend"
112+
href="/docs/concepts/architecture"
113+
description="Protocol adapters for Postgres, MongoDB, REST and GraphQL. Write once, run on any infrastructure."
114+
/>
115+
</div>
116+
117+
{/* Personas Section */}
118+
<div className="mt-32 mb-16 w-full max-w-5xl px-4">
119+
<h2 className="text-3xl font-bold tracking-tight mb-12 bg-gradient-to-r from-fd-foreground to-fd-muted-foreground bg-clip-text text-transparent">
120+
Built for Builders
121+
</h2>
122+
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
123+
<PersonaCard
124+
icon={<LayoutTemplate className="w-8 h-8 mb-4 text-blue-500" />}
125+
title="Platform Architects"
126+
description="Design scalable Internal Developer Platforms (IDP) that unify your data silos."
127+
href="/docs/concepts/enterprise-patterns"
128+
action="Explore Patterns"
129+
/>
130+
<PersonaCard
131+
icon={<Bot className="w-8 h-8 mb-4 text-purple-500" />}
132+
title="AI Engineers"
133+
description="Feed LLMs with perfectly structured, deterministic JSON schemas they can actually understand."
134+
href="/docs/concepts/ai-codex"
135+
action="View Codex"
136+
/>
137+
<PersonaCard
138+
icon={<Cpu className="w-8 h-8 mb-4 text-green-500" />}
139+
title="Framework Builders"
140+
description="Implement the protocol in your language. Write drivers for React, Vue, Flutter, or Go."
141+
href="/docs/specifications/data/architecture"
142+
action="Read Spec"
143+
/>
144+
</div>
145+
</div>
146+
147+
</main>
148+
</HomeLayout>
149+
);
150+
}
151+
152+
function FeatureCard({ icon, title, description, href }: { icon: React.ReactNode; title: string; description: string; href?: string }) {
153+
const CardContent = (
154+
<div className="group relative h-full rounded-2xl border border-fd-border bg-fd-card p-6 shadow-sm transition-all hover:border-fd-primary/20 hover:shadow-md hover:shadow-fd-primary/5 cursor-pointer">
155+
<div className="mb-4 inline-flex items-center justify-center rounded-lg bg-fd-primary/10 p-2 text-fd-primary transition-colors group-hover:bg-fd-primary/20">
156+
{icon}
157+
</div>
158+
<h3 className="mb-2 text-lg font-semibold text-fd-card-foreground group-hover:text-fd-primary transition-colors">
159+
{title}
160+
</h3>
161+
<p className="text-sm text-fd-muted-foreground leading-relaxed">
162+
{description}
163+
</p>
164+
</div>
165+
);
166+
167+
if (href) {
168+
return (
169+
<Link href={href} className="block h-full">
170+
{CardContent}
171+
</Link>
172+
);
173+
}
174+
175+
return CardContent;
176+
}
177+
178+
function PersonaCard({ icon, title, description, href, action }: { icon: React.ReactNode; title: string; description: string; href: string; action: string }) {
179+
return (
180+
<Link href={href} className="flex flex-col items-start p-8 rounded-2xl bg-fd-secondary/30 border border-fd-border/50 hover:bg-fd-secondary/60 hover:border-fd-primary/30 transition-all group text-left">
181+
{icon}
182+
<h3 className="text-xl font-bold mb-3">{title}</h3>
183+
<p className="text-fd-muted-foreground mb-6 text-sm leading-relaxed flex-grow text-left">
184+
{description}
185+
</p>
186+
<div className="flex items-center text-sm font-semibold text-fd-primary mt-auto group-hover:translate-x-1 transition-transform">
187+
{action} <span className="ml-1"></span>
188+
</div>
189+
</Link>
190+
)
191+
}

apps/docs/app/docs/layout.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

apps/docs/app/layout.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import './global.css';
2-
import { RootProvider } from 'fumadocs-ui/provider/next';
2+
import { redirect } from 'next/navigation';
33
import type { ReactNode } from 'react';
44
import type { Metadata } from 'next';
5+
import { i18n } from '@/lib/i18n';
56

67
export const metadata: Metadata = {
78
title: {
@@ -14,12 +15,8 @@ export const metadata: Metadata = {
1415
},
1516
};
1617

17-
export default function Layout({ children }: { children: ReactNode }) {
18-
return (
19-
<html lang="en" suppressHydrationWarning>
20-
<body>
21-
<RootProvider>{children}</RootProvider>
22-
</body>
23-
</html>
24-
);
18+
export default function RootLayout({ children }: { children: ReactNode }) {
19+
// Root layout is only used for redirects with middleware
20+
// The actual layout is in [lang]/layout.tsx
21+
return children;
2522
}

0 commit comments

Comments
 (0)