diff --git a/mdx-components.tsx b/mdx-components.tsx index b9a5ba7..8eae550 100644 --- a/mdx-components.tsx +++ b/mdx-components.tsx @@ -105,5 +105,28 @@ export function getMDXComponents(components: MDXComponents): MDXComponents { // Collapsible sections details: (props) =>
, summary: (props) => , + + // Buttons (handle onclick string from transformerCopyButton) + button: ({ children, onClick, ...props }: { children?: React.ReactNode; onClick?: string | (() => void); className?: string } & Record) => { + if (typeof onClick === 'string') { + const className = (props.className as string) ?? ''; + return ( + ` + }} + suppressHydrationWarning + /> + ); + } + return ( + + ); + }, } }