Rspress has a built-in preview page, the effect is as follows:
Generating the preview page requires the following two steps:
For example, create the following directories and files
├── docs
│ ├── index.md
│ ├── api
│ │ ├── index.md
│ │ ├── theme
│ │ │ ├── component.mdx
│ │ │ ├── utils.mdx
// ...
We add the following to api/index.md
:
---
overview: true
---
_meta.json
The content structure of the preview page will be automatically generated according to _meta.json
and the corresponding h1, h2 titles of the article. For example, the configuration of api/_meta.json
is as follows:
[
{
"type": "dir",
"name": "theme",
"label": "Theme"
}
]
At the same time, the file api/theme/_meta.json
has the following content:
["component", "utils"]
The detailed configuration usage of
_meta.json
can be referred to Auto Nav/Sidebar.
In the above configuration, the final preview page will generate a group called Theme
, which contains the h1, h2 titles of two articles: component.md(x)
and utils.md(x)
. Of course, you can also refer to the config of the Theme
group to add more groups.