import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import { makeHeadingSlugger, isInDocumentHref } from '@/lib/markdown-anchors' // Docs-brand markdown renderer. Unlike components/markdown.tsx (which is bound // to the management app's theme tokens), this emits headings with stable anchor // ids and otherwise leans on the `.docs-prose` stylesheet in docs.css so the // output matches the public site's dark / monospace / lime aesthetic. // // Content here is author-trusted (checked-in .md), but we still never enable // rehypeRaw, so any stray HTML stays inert. export function DocsMarkdown({ content }: { content: string }) { const slug = makeHeadingSlugger() return (
react-markdown wraps a lone image in) styled as blocks; the alt
// text doubles as the caption.
img: ({ src, alt }) =>
typeof src === 'string' ? (
{/* eslint-disable-next-line @next/next/no-img-element */}
{alt ? {alt} : null}
) : null,
a: ({ href, children }) =>
isInDocumentHref(href) ? (
{children}
) : (
{children}
),
}}
>
{content}