Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(md): global custom container titles #3112

Merged
merged 3 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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