Skip to main content

Agent 消息处理

· One min read
marvin-season
Maintainer of Docusaurus

细化处理单个消息

type Content = {
type: 'text',
text: string;
} | {
type: 'agent',
agent: string; // custom html tag, just like <agent attr="attr"></agent>
}

映射富文本组件

md也是富文本的一种

const components: Components & {
agent?: React.ElementType
} = {
agent: ({ node, ...props }) => <Agent {...props} />,
}

<Markdown rehypePlugins={[rehypeRaw]} components={components}>
{contentValue}
</Markdown>

rehypeRaw 允许解析 html, components 允许自定义组件