Skip to content
快速定位

vitepress-plugin-runcode

A vitepress plugin that run js code in markdown.

version

Install

sh
npm install vitepress-plugin-runcode

Usage

In .vitepress/theme/index.ts

ts
import RunCode from 'vitepress-plugin-runcode'
// css
import 'vitepress-plugin-runcode/styles.css'

export default {
  enhanceApp({ app }) {
    app.use(RunCode)
  }
}

In your markdown

Tips

Running js code online is based on new Function, so you need to use ";" specify the end of the code.

md
<RunCode>

```js
const num1 = 8;
const num2 = 10;

return num1 + num2;
```

</RunCode>

Released under the MIT License