mirror of
https://github.com/supabase/supabase.git
synced 2026-05-14 14:49:37 +08:00
## Problem We'd like to update react to `19` but many of our dependencies don't support it. ## Solution Update those dependencies. This PR focuses on `react-markdown` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Upgraded react-markdown to 10.1.0 (and remark-gfm to 4.0.0) across projects for improved Markdown support. * **Style** * Adjusted Markdown rendering so typography and spacing are applied via surrounding containers, improving consistent styling across docs and UI. * **New Content** * Added a new RSS feed item for a recent blog post. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import { PropsWithChildren } from 'react'
|
|
import ReactMarkdown, { type Options } from 'react-markdown'
|
|
import remarkGfm from 'remark-gfm'
|
|
import { cn } from 'ui'
|
|
|
|
import { InlineLink } from '@/components/ui/InlineLink'
|
|
|
|
interface MarkdownProps extends Omit<Options, 'children' | 'node'> {
|
|
className?: string
|
|
/** @deprecated Should remove this and just take `children` instead */
|
|
content?: string
|
|
extLinks?: boolean
|
|
}
|
|
|
|
const H3 = ({
|
|
children,
|
|
}: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>) => (
|
|
<h3 className="mb-1">{children}</h3>
|
|
)
|
|
const Code = ({
|
|
children,
|
|
}: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>) => (
|
|
<code className="text-code-inline">{children}</code>
|
|
)
|
|
const A = ({
|
|
href,
|
|
children,
|
|
}: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>) => (
|
|
<InlineLink href={href ?? '/'}>{children}</InlineLink>
|
|
)
|
|
|
|
export const Markdown = ({
|
|
children,
|
|
className,
|
|
content = '',
|
|
extLinks = false,
|
|
...props
|
|
}: PropsWithChildren<MarkdownProps>) => {
|
|
return (
|
|
<div className={cn('text-sm', className)}>
|
|
<ReactMarkdown
|
|
remarkPlugins={[remarkGfm]}
|
|
components={{
|
|
h3: H3,
|
|
code: Code,
|
|
a: A,
|
|
}}
|
|
{...props}
|
|
>
|
|
{(children as string) ?? content}
|
|
</ReactMarkdown>
|
|
</div>
|
|
)
|
|
}
|