"use client"; import type { ReactNode } from "react"; import ReactMarkdown, { type Components } from "react-markdown"; import remarkGfm from "remark-gfm"; import { withCitationChips } from "./citation-chips"; type SelectFn = (citationId: string) => void; const PARAGRAPH = "mb-4 text-[15px] leading-7 text-[#111111] last:mb-0"; const HEADING = "mb-3 mt-6 font-black tracking-[-0.04em] text-[#111111] first:mt-0"; function chipped(children: ReactNode, onSelect: SelectFn): ReactNode { return withCitationChips(children, onSelect); } export function AnswerMarkdown({ answer, onCitationSelect, }: { answer: string; onCitationSelect: SelectFn; }) { const components: Components = { p: ({ children }) =>
{chipped(children, onCitationSelect)}
, h1: ({ children }) =>{children}), a: ({ children, href }) => ( {children} ), strong: ({ children }) => {children}, hr: () =>
{children}
),
code: ({ children, className }) => {
const isBlock = typeof className === "string" && className.includes("language-");
if (isBlock) {
return {children};
}
return (
{children}
);
},
img: () => null,
};
return (