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
We add the following to api/index.md:
The title of the overview page can be configured through frontmatter. The default value is Overview. After title is configured in frontmatter, there is no need to write an H1 title in the markdown content.
_meta.jsonThe content structure of the overview 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:
At the same time, the file api/theme/_meta.json has the following content:
The detailed configuration usage of
_meta.jsoncan 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.
If you want to control the headers displayed in the overview page, you can configure it through overviewHeaders config in _meta.json, which defaults to [2] and you can also configure FrontMatter with overviewHeaders: [2] in exact file.
If you want to generate a sub-preview page under theme, there are two ways:
theme.md with the same name in the parent directory of theme and configure the frontmatter of overview: true.index.md in the theme directory and configure the frontmatter of overview: true.Then configure theme/_meta.json as follows: