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.
It is recommended to use CodeBlockRuntime only when necessary, as it increases runtime bundle size, especially when multiple languages need to be included, and cannot benefit from compile-time highlighting performance.
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 just need to reference external files as code blocks, it is recommended to use the static file code block syntax, which is processed at compile time with better performance and smaller bundle size.