Skip to content

Commit a13f5cb

Browse files
djdjz7brc-dd
andauthored
docs(md): global custom container titles (#3112)
Co-authored-by: Divyansh Singh <[email protected]>
1 parent 62f0e4f commit a13f5cb

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

Diff for: docs/guide/markdown.md

+22-5
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,25 @@ console.log('Hello, VitePress!')
206206
```
207207
:::
208208

209+
Also, you may set custom titles globally by adding the following content in site config, helpful if not writing in English:
210+
211+
```ts
212+
// config.ts
213+
export default defineConfig({
214+
// ...
215+
markdown: {
216+
container: {
217+
tipLabel: '提示',
218+
warningLabel: '警告',
219+
dangerLabel: '危险',
220+
infoLabel: '信息',
221+
detailsLabel: '详细信息'
222+
}
223+
}
224+
// ...
225+
})
226+
```
227+
209228
### `raw`
210229

211230
This is a special container that can be used to prevent style and router conflicts with VitePress. This is especially useful when you're documenting component libraries. You might also wanna check out [whyframe](https://whyframe.dev/docs/integrations/vitepress) for better isolation.
@@ -230,11 +249,9 @@ Wraps in a <div class="vp-raw">
230249

231250
```js
232251
import { postcssIsolateStyles } from 'vitepress'
233-
252+
234253
export default {
235-
plugins: [
236-
postcssIsolateStyles()
237-
]
254+
plugins: [postcssIsolateStyles()]
238255
}
239256
```
240257

@@ -548,7 +565,7 @@ const line3 = 'This is line 3'
548565
// line-numbers is enabled and start from 2
549566
const line3 = 'This is line 3'
550567
const line4 = 'This is line 4'
551-
````
568+
```
552569

553570
## Import Code Snippets
554571

Diff for: docs/reference/site-config.md

+9
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,15 @@ interface MarkdownOptions extends MarkdownIt.Options {
532532
// You can also pass options to `markdown-it-mathjax3` here.
533533
// See: https://github.com/tani/markdown-it-mathjax3#customization
534534
math?: any
535+
536+
// Global custom container titles
537+
container?: {
538+
infoLabel?: string
539+
tipLabel?: string
540+
warningLabel?: string
541+
dangerLabel?: string
542+
detailsLabel?: string
543+
}
535544
}
536545
```
537546

0 commit comments

Comments
 (0)