🚧 Rspress 2.0 document is under development
close

CodeBlockRuntime non-ejectable

Warning

This component is a non-ejectable one, and the code has a high degree of coupling with the core code. It's not recommended to customize it via wrap/eject.

CodeBlockRuntime renders runnable code blocks at runtime.

Usage

index.mdx
import { CodeBlockRuntime } from '@theme';

export default function Page() {
  return (
    <CodeBlockRuntime
      lang="js"
      title="index.js"
      code={`console.log('Hello World!')`}
      shikiOptions={{}}
    />
  );
}

Pass lang, title, and code to render the block; shikiOptions customizes highlighting.