markdown-container
Register markdown custom containers in your VuePress site.
This plugin simplifies the use of @mdit/plugin-container, but also retains its original capabilities.
Usage
npm i -D @vuepress/plugin-markdown-container@nextimport { markdownContainerPlugin } from '@vuepress/plugin-markdown-container'
export default {
plugins: [
markdownContainerPlugin({
// options
}),
],
}Container Syntax
::: <type> [info]
[content]
:::- The
typeis required and should be specified via type option. - The
infois optional, and the default value can be specified viadefaultInfoin locales option. - The
contentcan be any valid markdown content.
Tips
This plugin can be used multiple times to support different types of containers.
Options
stringThe type of the container.
It will be used as the name option of @mdit/plugin-container.
Record<string, { defaultInfo: string }>{}The default info of the container in different locales.
If this option is not specified, the default info will fallback to the uppercase of the type option.
export default {
plugins: [
markdownContainerPlugin({
type: 'tip',
locales: {
'/': {
defaultInfo: 'TIP',
},
'/zh/': {
defaultInfo: '提示',
},
},
}),
],
}See also: Guide > I18n.
stringThe default info of the container in this locale.
(info: string) => stringA function to render the starting tag of the container.
The first param is the info part of container syntax.
This option will not take effect if you don't specify the after option.
Its default value is:
;(info: string): string =>
`<div class="custom-container ${type}">${info ? `<p class="custom-container-title">${info}</p>` : ''}\n`(info: string) => string(): string => '</div>\n'A function to render the ending tag of the container.
The first param is the info part of container syntax.
This option will not take effect if you don't specify the before option.
MarkdownItContainerRenderFunctionThe render function of the container.
It will be used as both the openRenderer and closeRenderer options of @mdit/plugin-container.
This plugin uses a default render function. If you specify this option, the default render function will be replaced, and the locales, before and after options will be ignored.
Its type is:
type MarkdownItContainerRenderFunction = (
tokens: Token[],
index: number,
options: unknown,
env: MarkdownEnv,
self: Renderer,
) => string(params: string) => booleanThe validate option of @mdit/plugin-container.
