Skip to content
Preview

Preview

Posted Updated
By 廿四2 min Read

The theme provides you preview support.

Settings

.vitepress/config.ts
ts
import { defineConfig } from 'vitepress-theme-niansi'

export default defineConfig({
  markdown: {
    plugins: {
      preview: true
    }
  }
})

Usage

You can use a preview container to display a piece of content and it's source code.

If the displayed code differs from the source code of content, you can also use <Preview> component with its code and content slots.

Demo

Some content here.

Optional title
md
Some content here.

Hello, world!

js
document.innerHTML = "Hello, world!";
Demo
md
::: preview Optional title

Some content here.

:::

<Preview>

<template #code>

```js
document.innerHTML = "Hello, world!";
```

</template>
<template #content>

Hello, world!

</template>

</Preview>

Changelog

2026-04-18 23:32
View All Changelog