Skip to content

Commit

Permalink
docs(md): global custom container titles (#3112)
Browse files Browse the repository at this point in the history
Co-authored-by: Divyansh Singh <[email protected]>
  • Loading branch information
djdjz7 and brc-dd authored Oct 21, 2023
1 parent 62f0e4f commit a13f5cb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
27 changes: 22 additions & 5 deletions docs/guide/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,25 @@ console.log('Hello, VitePress!')
```
:::

Also, you may set custom titles globally by adding the following content in site config, helpful if not writing in English:

```ts
// config.ts
export default defineConfig({
// ...
markdown: {
container: {
tipLabel: '提示',
warningLabel: '警告',
dangerLabel: '危险',
infoLabel: '信息',
detailsLabel: '详细信息'
}
}
// ...
})
```

### `raw`

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.
Expand All @@ -230,11 +249,9 @@ Wraps in a <div class="vp-raw">

```js
import { postcssIsolateStyles } from 'vitepress'

export default {
plugins: [
postcssIsolateStyles()
]
plugins: [postcssIsolateStyles()]
}
```

Expand Down Expand Up @@ -548,7 +565,7 @@ const line3 = 'This is line 3'
// line-numbers is enabled and start from 2
const line3 = 'This is line 3'
const line4 = 'This is line 4'
````
```

## Import Code Snippets

Expand Down
9 changes: 9 additions & 0 deletions docs/reference/site-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,15 @@ interface MarkdownOptions extends MarkdownIt.Options {
// You can also pass options to `markdown-it-mathjax3` here.
// See: https://github.com/tani/markdown-it-mathjax3#customization
math?: any

// Global custom container titles
container?: {
infoLabel?: string
tipLabel?: string
warningLabel?: string
dangerLabel?: string
detailsLabel?: string
}
}
```

Expand Down

0 comments on commit a13f5cb

Please sign in to comment.