markdown-field
Add fields to your VuePress site.
Usage
npm i -D @vuepress/plugin-markdown-field@nextimport { markdownFieldPlugin } from '@vuepress/plugin-markdown-field'
export default {
plugins: [
markdownFieldPlugin({
// Enable fields
fields: true,
}),
],
}Syntax
You can use ::: fields container to describe field information, including field name, type, whether it's required, default value, etc.
Inside the container, lines starting with @name@ are field items. Attributes are appended after the closing @.
::: fields
@theme@ type="ThemeConfig" required default="{ base: '/' }"
Theme Config
@enabled@ type="boolean" optional default="true"
Whether it's enabled
:::By default, all attributes are allowed and displayed as-is. Common attributes include type, required, optional, default and deprecated.
typeis displayed as a code block in the field header.defaultis displayed as a labeled code block below the field header.required,optionalanddeprecatedare displayed as badges, and a deprecated field's name is colored red and struck through.- Other attributes are displayed as
Name: valuebadges.
Nesting
Fields can be nested to describe fields of an object type. To create a field item inside another field, increase the starting @ by one for each level of nesting.
::: fields
@options@ type="object"
Options.
@@options.name@ type="string"
Option name.
@other@ type="string"
Other field.
:::For more syntax details, see @mdit/plugin-field.
Demo
themeRequired
ThemeConfigDefault
{ base: '/' }Theme Config
enabledOptional
booleanDefault
trueWhether it's enabled
otherDeprecated
stringDeprecated field
Options
fields
- Type:
boolean - Details: Whether to enable fields.
locales
- Type:
MarkdownFieldPluginLocaleConfig
interface MarkdownFieldPluginLocaleData {
/**
* Label text for the `default` attribute
*/
default: string
/**
* Badge text for the `required` attribute
*/
required: string
/**
* Badge text for the `optional` attribute
*/
optional: string
/**
* Badge text for the `deprecated` attribute
*/
deprecated: string
}- Details: Locale config for badge texts.
