Multi version
Rspress's default theme supports multi-version document management. Next, we will introduce how to access multi-version documents.
multiVersion config
Configure the version list and default version through multiVersion, for example:
Here, default is the default version, and versions is the version list.
Adding multi-version documents
According to the version list you configured, add multi-version documents under the docs directory, for example:
In Rspress's conventional routing, for the default version, the version path prefix will be automatically omitted. For example, v1/index.mdx will be rendered as the / route, while v2/index.mdx will be rendered as the /v2/ route.
For links in the document, you do not need to manually add the version prefix. Rspress will automatically add the corresponding version prefix according to the version of the current document. For example, the link /guide/ in v2/index.mdx will be rendered as /v2/guide/.
Using with i18n
Multi-version can be used together with internationalization. When both are enabled, the directory structure uses version as the top level, then language subdirectories within each version:
The document directory structure should be organized as follows:
The generated routes follow the pattern /{version}/{lang}/:
Get the current version in components
In components, you can get the current version through useVersion, for example:
Version-specific search
By default, search.versioned is true, which means the search will only query the index corresponding to the currently selected version. If you want to search across all versions, you can set it to false: