https://github.com/nonebot/vuepress-plugin-versioning
https://github.com/nonebot/vuepress-plugin-versioning
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nonebot/vuepress-plugin-versioning
- Owner: nonebot
- License: apache-2.0
- Created: 2020-10-12T13:20:32.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-17T06:43:08.000Z (over 5 years ago)
- Last Synced: 2025-07-11T02:38:30.086Z (12 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# vuepres-plugin-versioning
Versioning plugin for VuePress
Inspired by
## Usage
Install the plugin
```bash
npm i -D git+https://github.com/nonebot/vuepress-plugin-versioning
```
and enable it in your .vuepress/config.js
```js
module.exports = {
plugins: ["versioning"],
};
```
Config plugin
```js
const path = require("path");
const fs = require("fs-extra");
module.exports = (context) => ({
plugins: [
[
"versioning",
{
// Dir to store achieved version docs
versionedSourceDir: path.resolve(context.sourceDir, "..", "archive"),
// Dir to store extra pages that not within versioning
pagesSourceDir: path.resolve(context.sourceDir, "..", "pages"),
async onNewVersion(
version /*version str*/,
versionDestPath /*version dir*/
) {
// Copy extra files on achieve
return fs.copy(
context.sourceDir,
"api.json",
path.join(versionDestPath, "api.json")
);
},
},
],
],
});
```
## Routing
Once you have created your first version, the plugin will change the default routing to the latest achieved version. Docs in the vuepress source directory will be considered as part of the version `next` and they are available under the URL `/next/`. All other versions will be available under their respective version number like `/1.0.0/`.
## Access Version Data
The plugin will automatically store the version information in the page metadata. You can access it in components via `this.$page.version`. To get a list of all versions that are currently available you can use `this.$versions`