Skip to content

Commit

Permalink
Pass chat_id to MDX runtime for context-aware rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Feb 19, 2025
1 parent c25a4be commit 5803a35
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/xgen/components/chat/text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const components = {
}

const Index = (props: IProps) => {
const { text } = props
const [content, setContent] = useState<any>()
const { text, chat_id } = props
const [content, setContent] = useState<any>('')
const mdxComponents = useMDXComponents(components)

useAsyncEffect(async () => {
Expand Down Expand Up @@ -100,14 +100,15 @@ const Index = (props: IProps) => {
const { default: Content } = await run(compiledSource, {
...JsxRuntime,
Fragment,
useMDXComponents: () => mdxComponents
useMDXComponents: () => mdxComponents,
chat_id
})
setContent(Content)
} catch (err) {
console.error(err)
console.log(`original text:\n`, text)
}
}, [text])
}, [text, chat_id])

return <div className={styles._local}>{content}</div>
}
Expand Down

0 comments on commit 5803a35

Please sign in to comment.