MDX 指南

Front Matter

input

1---
2title : "Hello World"
3---
4# {frontmatter.title}

output

1<h1>Hello World</h1>

Custom Container

input

1:::details 此处有一细节
2This is a `block` of `Custom Title`
3:::

output

此处有一细节

This is a block of Custom Title

参考

标签名 解释
tip 提示
warning 警告
danger 危险
details 细节
note 注释

Code Block

Show Title

input

```js title="Hello World" console.log('Hello World') ```

output

Hello World
1console.log('Hello World')

代码标题

If you want to display line numbers, you can enable the showLineNumbers option in the config file:

rspress.config.ts
1export default {
2  // ...
3  markdown: {
4    showLineNumbers: true,
5  },
6};

Line Highlighting

input

1```js title="hello.js" {1,3-5} 
2console.log(1)
3console.log(2)
4console.log(3)
5console.log(4)
6console.log(5)
7console.log(6)
8```

output

hello.js
1console.log(1)
2console.log(2)
3console.log(3)
4console.log(4)
5console.log(5)
6console.log(6)