first commit
This commit is contained in:
48
app/docs/[...slug]/page.tsx
Normal file
48
app/docs/[...slug]/page.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { getDocBySlug, getAllDocSlugs } from "../../../lib/docs";
|
||||
import { DocContent } from "../../../components/DocContent";
|
||||
import { notFound } from "next/navigation";
|
||||
import { Metadata } from "next";
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const slugs = getAllDocSlugs();
|
||||
return slugs.map((slug) => ({
|
||||
slug,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params }: { params: Promise<{ slug: string[] }> }
|
||||
): Promise<Metadata> {
|
||||
const resolvedParams = await params;
|
||||
const slug = resolvedParams?.slug || [];
|
||||
const doc = await getDocBySlug(slug);
|
||||
if (!doc) {
|
||||
return {
|
||||
title: "Not Found",
|
||||
};
|
||||
}
|
||||
return {
|
||||
title: doc.meta.title,
|
||||
description: doc.meta.description || doc.meta.summary,
|
||||
};
|
||||
}
|
||||
|
||||
export default async function DocPage({ params }: { params: Promise<{ slug: string[] }> }) {
|
||||
const resolvedParams = await params;
|
||||
const slug = resolvedParams?.slug || [];
|
||||
const doc = await getDocBySlug(slug);
|
||||
|
||||
if (!doc) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<article className="doc-page-container">
|
||||
<h1 className="text-4xl font-bold mb-4">{doc.meta.title}</h1>
|
||||
{doc.meta.description && (
|
||||
<p className="text-xl text-gray-500 dark:text-gray-400 mb-8">{doc.meta.description}</p>
|
||||
)}
|
||||
<DocContent contentHtml={doc.contentHtml} />
|
||||
</article>
|
||||
);
|
||||
}
|
||||
19
app/docs/layout.tsx
Normal file
19
app/docs/layout.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Sidebar } from "../../components/Sidebar";
|
||||
import { getSidebarStructure } from "../../lib/docs";
|
||||
|
||||
export default function DocsLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const sidebarData = getSidebarStructure();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Sidebar sidebarData={sidebarData} />
|
||||
<main className="doc-main">
|
||||
{children}
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
}
|
||||
374
app/globals.css
Normal file
374
app/globals.css
Normal file
@@ -0,0 +1,374 @@
|
||||
:root {
|
||||
--bg-primary: #ffffff;
|
||||
--bg-secondary: #f8fafc;
|
||||
--bg-sidebar: #f1f5f9;
|
||||
--text-primary: #1e293b;
|
||||
--text-secondary: #475569;
|
||||
--text-muted: #94a3b8;
|
||||
--border-color: #e2e8f0;
|
||||
--accent-primary: #3b82f6;
|
||||
--accent-hover: #2563eb;
|
||||
--accent-glow: rgba(59, 130, 246, 0.1);
|
||||
--sidebar-width: 280px;
|
||||
--header-height: 64px;
|
||||
}
|
||||
|
||||
[data-theme="dark"] {
|
||||
--bg-primary: #0f172a;
|
||||
--bg-secondary: #1e293b;
|
||||
--bg-sidebar: #0b1120;
|
||||
--text-primary: #f8fafc;
|
||||
--text-secondary: #cbd5e1;
|
||||
--text-muted: #64748b;
|
||||
--border-color: #334155;
|
||||
--accent-primary: #60a5fa;
|
||||
--accent-hover: #93c5fd;
|
||||
--accent-glow: rgba(96, 165, 250, 0.15);
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
transition: background-color 0.3s ease, color 0.3s ease;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
/* --- Layout --- */
|
||||
.doc-main {
|
||||
margin-left: var(--sidebar-width);
|
||||
min-height: 100vh;
|
||||
padding: 3rem 4rem;
|
||||
background-color: var(--bg-primary);
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.doc-main {
|
||||
margin-left: 0;
|
||||
padding: 2rem 1.5rem;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Sidebar Styles --- */
|
||||
.sidebar {
|
||||
width: var(--sidebar-width);
|
||||
height: 100vh;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
background-color: var(--bg-sidebar);
|
||||
border-right: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 50;
|
||||
transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
height: var(--header-height);
|
||||
padding: 0 1.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
background-color: var(--bg-sidebar);
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.sidebar-logo-icon {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.sidebar-logo-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar-logo-title {
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
font-size: 1.125rem;
|
||||
line-height: 1.2;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
.sidebar-logo-subtitle {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.5rem 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
/* Scrollbar for sidebar */
|
||||
.sidebar-nav::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.sidebar-nav::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.sidebar-nav::-webkit-scrollbar-thumb {
|
||||
background-color: var(--border-color);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.sidebar-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.sidebar-section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-primary);
|
||||
cursor: pointer;
|
||||
border-radius: 0.375rem;
|
||||
transition: background-color 0.2s;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.sidebar-section-title:hover {
|
||||
background-color: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.sidebar-section-title.active {
|
||||
color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.sidebar-section-arrow {
|
||||
font-size: 0.6rem;
|
||||
color: var(--text-muted);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.sidebar-section-arrow.open {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.sidebar-section-children {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-left: 1rem;
|
||||
border-left: 1px solid var(--border-color);
|
||||
padding-left: 0.5rem;
|
||||
gap: 0.15rem;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.sidebar-link,
|
||||
.sidebar-root-link {
|
||||
display: block;
|
||||
padding: 0.4rem 0.75rem;
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-secondary);
|
||||
text-decoration: none;
|
||||
border-radius: 0.375rem;
|
||||
transition: all 0.2s ease;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.sidebar-link:hover,
|
||||
.sidebar-root-link:hover {
|
||||
background-color: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.sidebar-link.active,
|
||||
.sidebar-root-link.active {
|
||||
color: var(--accent-primary);
|
||||
background-color: var(--accent-glow);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* --- DocContent (Markdown) Styles --- */
|
||||
.doc-article {
|
||||
color: var(--text-primary);
|
||||
line-height: 1.75;
|
||||
font-size: 1.05rem;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.doc-article h1,
|
||||
.doc-article h2,
|
||||
.doc-article h3,
|
||||
.doc-article h4,
|
||||
.doc-article h5,
|
||||
.doc-article h6 {
|
||||
color: var(--text-primary);
|
||||
font-weight: 700;
|
||||
margin-top: 2.5rem;
|
||||
margin-bottom: 1rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.doc-article h1 {
|
||||
font-size: 2.5rem;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
.doc-article h2 {
|
||||
font-size: 1.875rem;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
padding-bottom: 0.5rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.doc-article h3 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.doc-article h4 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.doc-article p {
|
||||
margin-bottom: 1.5rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.doc-article a {
|
||||
color: var(--accent-primary);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s;
|
||||
border-bottom: 1px transparent;
|
||||
}
|
||||
|
||||
.doc-article a:hover {
|
||||
color: var(--accent-hover);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.doc-article ul,
|
||||
.doc-article ol {
|
||||
margin-bottom: 1.5rem;
|
||||
padding-left: 1.5rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.doc-article li {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.doc-article li::marker {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.doc-article img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.5rem;
|
||||
margin: 1.5rem 0;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.doc-article code {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
background-color: var(--bg-secondary);
|
||||
padding: 0.2rem 0.4rem;
|
||||
border-radius: 0.25rem;
|
||||
font-size: 0.875em;
|
||||
color: var(--accent-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.doc-article pre {
|
||||
background-color: #0f172a;
|
||||
color: #f8fafc;
|
||||
padding: 1.25rem;
|
||||
border-radius: 0.5rem;
|
||||
overflow-x: auto;
|
||||
margin: 1.5rem 0;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
/* Ignore nested code styling inside pre */
|
||||
.doc-article pre code {
|
||||
background-color: transparent;
|
||||
padding: 0;
|
||||
color: inherit;
|
||||
font-size: 0.9em;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.doc-article blockquote {
|
||||
border-left: 4px solid var(--accent-primary);
|
||||
padding: 1rem 1.25rem;
|
||||
margin: 1.5rem 0;
|
||||
color: var(--text-muted);
|
||||
font-style: italic;
|
||||
background-color: var(--bg-secondary);
|
||||
border-radius: 0 0.5rem 0.5rem 0;
|
||||
}
|
||||
|
||||
.doc-article blockquote p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.doc-article table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 2rem 0;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.doc-article th,
|
||||
.doc-article td {
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid var(--border-color);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.doc-article th {
|
||||
background-color: var(--bg-secondary);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.doc-article td {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.doc-article hr {
|
||||
border: 0;
|
||||
border-top: 1px solid var(--border-color);
|
||||
margin: 3rem 0;
|
||||
}
|
||||
|
||||
/* Title container wrapper inside article to strip Tailwind prose max-width constraint */
|
||||
article {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
24
app/layout.tsx
Normal file
24
app/layout.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { Metadata } from "next";
|
||||
import { ThemeProvider } from "../components/ThemeProvider";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "OpenClaw Documentation",
|
||||
description: "OpenClaw 中文文档",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="zh-CN" suppressHydrationWarning>
|
||||
<body>
|
||||
<ThemeProvider>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
5
app/page.tsx
Normal file
5
app/page.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default function Home() {
|
||||
redirect("/docs/start/getting-started");
|
||||
}
|
||||
Reference in New Issue
Block a user