docs icon indicating copy to clipboard operation
docs copied to clipboard

Code block snippet

Open abrahamcl opened this issue 4 months ago • 3 comments

I'd like to be able to write reusable snippets to parametrize the inside of a code block.

As a simple example, I'd like to do something like

export const MyCurlFunction = ({ url }) => {
  const codeExample = `curl -X GET "${url}"`
  return (
    <Code>
      content=codeExample,
      language='bash'
    </Code>
  );
}

<MyCurlFunction 
  url="https://mintlify.com/docs/code"
/>

And this should be equivalent to:

```
curl -X GET "https://mintlify.com/docs/code"
```

As of now, this is not possible since jsx does not work inside backticks (obviously). I expected a way to directly call the Code component in jsx templates, but I could not make it work. I would you solve this?

abrahamcl avatar Aug 06 '25 19:08 abrahamcl