From a13f5cb3a77684ff3c8039d7b7b8065e8479ee69 Mon Sep 17 00:00:00 2001 From: Jason Dai Date: Sat, 21 Oct 2023 14:52:59 +0800 Subject: [PATCH] docs(md): global custom container titles (#3112) Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- docs/guide/markdown.md | 27 ++++++++++++++++++++++----- docs/reference/site-config.md | 9 +++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/docs/guide/markdown.md b/docs/guide/markdown.md index bff269d0..1541f11d 100644 --- a/docs/guide/markdown.md +++ b/docs/guide/markdown.md @@ -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. @@ -230,11 +249,9 @@ Wraps in a
```js import { postcssIsolateStyles } from 'vitepress' - + export default { - plugins: [ - postcssIsolateStyles() - ] + plugins: [postcssIsolateStyles()] } ``` @@ -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 diff --git a/docs/reference/site-config.md b/docs/reference/site-config.md index ea5d4f38..18814dd0 100644 --- a/docs/reference/site-config.md +++ b/docs/reference/site-config.md @@ -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 + } } ```