import { promises as fs } from 'fs';
import path from 'path';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
async function getMarkdownContent() {
// process.cwd() is the root of the Next.js project (the 'frontend' directory)
const mdPath = path.join(process.cwd(), '..', 'docs', 'design.md');
try {
const content = await fs.readFile(mdPath, 'utf8');
return content;
} catch (error) {
console.error("Failed to read design.md:", error);
return "# 文档加载失败\n\n无法读取 `docs/design.md` 文件。请检查文件是否存在以及服务器权限。";
}
}
export default async function DocsPage() {
const content = await getMarkdownContent();
return (
,
h2: ({node, ...props}) => ,
h3: ({node, ...props}) => ,
p: ({node, ...props}) => ,
ul: ({node, ...props}) => ,
ol: ({node, ...props}) =>
,
li: ({node, ...props}) => ,
code: ({node, inline, className, children, ...props}: any) => {
const match = /language-(\w+)/.exec(className || '');
return !inline ? (
{children}
) : (
{children}
);
},
pre: ({children}) => {children},
table: ({node, ...props}) => ,
th: ({node, ...props}) => | ,
td: ({node, ...props}) => | ,
a: ({node, ...props}) => ,
}}
>
{content}
);
}