Thanks to the Twoslash integration of Shiki, the default code syntax highlighter, it is as simple as adding a transformer.
Add to your Shiki transformers.
Example for Fumadocs MDX
Add required styles and components, note that you have to configure Tailwind CSS and the official Tailwind CSS plugin first.
Now you can add twoslash
meta string to codeblocks.
Learn more about Twoslash notations.
To use it on Next.js runtime, add typescript
and twoslash
to serverExternalPackages
:
Install the external dependencies:
Pass the transformer to Shiki, see https://shiki.style/packages/next for details.