FrontMatter refers to the part where the text is configured at the top of the file. In dumi, FrontMatter is written in YAML syntax; in addition to the Markdown file, dumi also supports the configuration of FrontMatter for demo display in the demo. Let’s look at two Examples:
Write FrontMatter in Markdown file:
---title: The title content---
Write FrontMatter in the demo:
/*** title: The title content*/
Both the form of code blocks and external demos support FrontMatter. The external demos not only support configuration in the source code, but also add attributes to the code
tag for configuration, such as:
<code src="/path/to/demo.tsx" title="This way you can also configure the demo title"></code>
String
Configure the page title, which will be used as the subtitle of the page title and the left menu.
Boolean
true
Control the display of the sidebar menu.
false | 'content' | 'menu'
'content'
Control the presentation or position of the anchor directory. When the value is false
, it will not be presented. When the value is content
, it will be presented on the right side of the content area (Affix Menu). When the value is menu
, the anchor of the current route will be presented in the left menu.
Number
null
Control the sorting order of the document, the smaller the value, the higher the sort.
String
null
Links to the old path of the document (specify from the root path) to avoid getting 404
from the original path after migrating from other documents to dumi.
Object
null
This configuration is used to group the current page so that it can be grouped and presented in the sidebar menu. We can generate group by configuring the group
through the next three FrontMatter configurations, or automatically based on dumi's folder nesting, for example:
.└── src/├── components/├── index.md├── a.md├── b.md
dumi will automatically specify group.title
as Components
and specify group.path
as /components
for index.md
, a.md
, and b.md
. And we can use FrontMatter to selectively copy the generated default configuration, such as:
---group:title: component---
Eventually, the group.path
will still generated to /components
, but group.title
generated to component
.
String
It is used to configure the name of the group in the sidebar menu. If it is not configured, it will read group.path
by default and convert it to title
. For example, /components
will be converted to Components
.
String
Required, configure the routes prefix of this group. When location.pathname
matches this prefix, the menu group will be marked as active.
Number
null
Control the presented order of the document, the smaller the value, the higher the sort.
Object
null
Only works in site mode, this configuration is used to manually specify the navigation menu where the current document is located. By default, it is automatically generated based on the first-level route path, and the sub-configurations are consistent with group
.
Omitted, same as group.title
.
Omitted, same as group.path
.
Omitted, same as group.order
.
Object
null
Only works in site mode, the page will be presented as a homepage after configuring.
String
null
Configure the title image of the homepage.
String
null
Configure the headline of the homepage.
String
null
Configure the introduction text of the homepage.
Array
null
Configure the operation buttons of the homepage. The last button will be presented as the primary button. The configurations are as follows:
hero:actions:- text: Getting Startedlink: /getting-started
Object
null
Only works in site mode. The page will be presented as the homepage after configuration, used to present the features of the component library in the form of 3 per line. The configuration format is as follows:
features:- icon: The URL of icon, recommended size is 144 * 144 (optional)title: Title contentlink: Support jump linkdesc: support `markdown` text
Markdown
null
Configure the footer of the current page. It is recommended to configure the home page. Currently, not support to configura all pages.
Boolean | String
false
Whether to present the 『Help Translation』 prompt at the top of the page. When set String
type, the prompt content will be customized.
Boolean
false
You can hide specific documentation that you do not want to display on the webpack in production env, and this option does not affect the development env.
String
null
It is used to configure the title of the demo, which will be presented in the Demo previewer.
Markdown
null
It is used to configure the description of the Demo, which will be presented in the Demo previewer, and support Markdown.
Boolean
false
Use to remove padding for demo container.
CSSPropertyValue
null
Use to configure background for demo container.
Boolean
false
It is used to indicate that the demo is a inline demo, which will be directly embedded in the document, and will not be wrapped by the demo wrapper, and users cannot view the source code.
Boolean
false
It is used to control whether the demo wrapper sets the CSS value of transform
to control the position of the elements of position: fixed;
relative to the demo wrapper.
Boolean
false
It is used to control whether the demo wrapper expands the presentation of source code by default.
Boolean
false
Mark this demo as debug demo, it means this demo will not render in production mode, in additional, dumi will render a DEV ONLY
badge for all debug demos in development mode, so that can help developers recognize them.
Array<'CSB' | 'EXTERNAL'>
[]
It is used to control the hiding of some function buttons of the Demo previewer. The configuration values have the following meanings:
Configure via the attributes of the code tag:
<!-- Attention, single quotes are required, to make sure the value is a valid JSON string --><code hideActions='["CSB"]' />
Configure via frontmatter:
/*** hideActions: ["CSB"]* hideActions:* - CSB*/// Both of the above methods can be identified
Boolean | Number
false
Use iframe mode to render this demo, it is very useful for layout demo, we can control the iframe height via pass a number value, check out iframe mode to get more informations.
String
Use to specific the URL to visit current demo, for example, we may hope to customize rendering URL for ReactNative demo, because dumi cannot render it directly.
In the default theme, this option only be applied when the iframe
mode enable; In the mobile theme, this option value will be used for the mobile device previewer in the right side.