Openstatus www.openstatus.dev
at 4c0f4c00a38753a5d0dfd7e7b7b7706dec6f1503 34 lines 923 B view raw
1import type { AnchorHTMLAttributes } from "react"; 2import { Fragment, createElement } from "react"; 3import { jsx, jsxs } from "react/jsx-runtime"; 4import rehypeReact from "rehype-react"; 5import remarkParse from "remark-parse"; 6import remarkRehype from "remark-rehype"; 7import { unified } from "unified"; 8 9export function ProcessMessage({ value }: { value: string }) { 10 const result = unified() 11 .use(remarkParse) 12 .use(remarkRehype) 13 .use(rehypeReact, { 14 createElement, 15 Fragment, 16 jsx, 17 jsxs, 18 components: { 19 a: (props: AnchorHTMLAttributes<HTMLAnchorElement>) => { 20 return ( 21 <a 22 target="_blank" 23 rel="noreferrer" 24 className="underline" 25 {...props} 26 /> 27 ); 28 }, 29 } as { [key: string]: React.ComponentType<unknown> }, 30 }) 31 .processSync(value).result; 32 33 return result; 34}