mirror of
https://github.com/supabase/supabase.git
synced 2026-06-20 16:26:02 +08:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { PropsWithChildren } from 'react'
|
|
import { ReactMarkdown, ReactMarkdownOptions } from 'react-markdown/lib/react-markdown'
|
|
import remarkGfm from 'remark-gfm'
|
|
import { cn } from 'ui'
|
|
|
|
import { InlineLink } from '@/components/ui/InlineLink'
|
|
|
|
interface MarkdownProps extends Omit<ReactMarkdownOptions, 'children' | 'node'> {
|
|
className?: string
|
|
/** @deprecated Should remove this and just take `children` instead */
|
|
content?: string
|
|
extLinks?: boolean
|
|
}
|
|
|
|
export const Markdown = ({
|
|
children,
|
|
className,
|
|
content = '',
|
|
extLinks = false,
|
|
...props
|
|
}: PropsWithChildren<MarkdownProps>) => {
|
|
return (
|
|
<ReactMarkdown
|
|
remarkPlugins={[remarkGfm]}
|
|
components={{
|
|
h3: ({ children }) => <h3 className="mb-1">{children}</h3>,
|
|
code: ({ children }) => <code className="text-code-inline">{children}</code>,
|
|
a: ({ href, children }) => <InlineLink href={href ?? '/'}>{children}</InlineLink>,
|
|
}}
|
|
{...props}
|
|
className={cn('text-sm', className)}
|
|
>
|
|
{(children as string) ?? content}
|
|
</ReactMarkdown>
|
|
)
|
|
}
|