feat(ui): add Markdown rendering components

Add CodeBlock, Markdown, StreamingMarkdown components with
Shiki syntax highlighting, GFM support, and linkify utility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Naiyuan Qing 2026-01-30 20:40:27 +08:00
parent 2a96fc9227
commit 9b87cd789e
9 changed files with 2130 additions and 53 deletions

View file

@ -1,7 +1,56 @@
"use client"
import { ComponentExample } from "@multica/ui/components/component-example";
import { Markdown } from "@multica/ui/components/markdown"
const MOCK_MD = `# Markdown 渲染器示例
**Markdown**
##
\`\`\`typescript
interface User {
id: string
name: string
email: string
}
async function fetchUser(id: string): Promise<User> {
const res = await fetch(\`/api/users/\${id}\`)
return res.json()
}
\`\`\`
##
- React
- Shiki
- GFM
##
| | | |
|------|------|------|
| | | Shiki |
| GFM | | remark-gfm |
| | | StreamingMarkdown |
##
>
> Dieter Rams
使 \`cn()\` 工具函数合并 class。
[](https://github.com)。
`
export default function Page() {
return <ComponentExample />;
}
return (
<div className="min-h-screen bg-background text-foreground flex items-center justify-center p-8">
<div className="max-w-2xl w-full">
<Markdown mode="full">{MOCK_MD}</Markdown>
</div>
</div>
)
}