markdown-container
为你的 VuePress 站点注册自定义容器。
该插件简化了 @mdit/plugin-container 的使用方法,但同时也保留了其原本的能力。
使用方法
npm i -D @vuepress/plugin-markdown-container@nextimport { markdownContainerPlugin } from '@vuepress/plugin-markdown-container'
export default {
plugins: [
markdownContainerPlugin({
// 配置项
}),
],
}容器语法
::: <type> [info]
[content]
:::type是必需的,应通过 type 配置项来指定。info是可选的,其默认值可以通过 locales 的defaultInfo配置项来指定。content可以是任何合法的 Markdown 内容。
提示
该插件可以被多次使用,以便支持不同类型的容器。
选项
type必填
string容器的类型。
它将会被用作 @mdit/plugin-container 的 name 配置项。
locales
Record<string, { defaultInfo: string }>默认值
{}容器在不同 locales 下的默认 info。
如果没有指定该配置项,默认 info 会使用大写的 type。
export default {
plugins: [
markdownContainerPlugin({
type: 'tip',
locales: {
'/': {
defaultInfo: 'TIP',
},
'/zh/': {
defaultInfo: '提示',
},
},
}),
],
}参考:指南 > 多语言支持。
locales.<localePath>.defaultInfo
string容器在该 locale 下的默认 info。
before
(info: string) => stringafter
(info: string) => string默认值
(): string => '</div>\n'render
MarkdownItContainerRenderFunction容器的渲染函数。
它将会被同时用作 @mdit/plugin-container 的 openRenderer 和 closeRenderer 配置项。
该插件使用了一个默认的 render 函数。但如果你指定了该配置项,那么默认的 render 函数就会被替换掉,此时 locales、before 和 after 配置项都会被忽略。
它的类型为:
type MarkdownItContainerRenderFunction = (
tokens: Token[],
index: number,
options: unknown,
env: MarkdownEnv,
self: Renderer,
) => stringvalidate
(params: string) => boolean@mdit/plugin-container 的 validate 配置项。
