Skip to content

Code block snippet #996

@abrahamcl

Description

@abrahamcl

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions