CodeBlockRuntime non-ejectable
This component currently does not support copying source code via the eject command. Custom Theme
CodeBlockRuntime renders runnable code blocks at runtime.
Usage
Pass lang, title, and code to render the block; shikiOptions customizes highlighting and also supports transformers.
Use CodeBlockRuntime only when necessary. It increases runtime bundle size, especially when multiple languages are included, and cannot benefit from compile-time highlighting.
Using shiki options
Here is an example using a transformer for line highlighting:
Importing file content
You can use the ?raw query to import file content as a string and pass it to the code prop. See Rsbuild - Static Assets for details.
This approach is suitable for scenarios where you need to dynamically display external file content, such as showing example code files.
If you only need to reference external files as code blocks, use the static file code block syntax. It is processed at compile time, with better performance and a smaller bundle size.