@viteplus/versions 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,183 +2,171 @@
2
2
 
3
3
  [![Documentation](https://img.shields.io/badge/Documentation-orange?logo=typescript&logoColor=f5f5f5)](https://viteplus.github.io/versions/)
4
4
  [![npm version](https://img.shields.io/npm/v/@viteplus/versions.svg)](https://www.npmjs.com/package/@viteplus/versions)
5
+ [![downloads](https://img.shields.io/npm/dm/@viteplus/versions?label=npm%20downloads)](https://www.npmjs.com/package/@viteplus/versions)
5
6
  [![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
6
- [![Node.js CI](https://github.com/viteplus/versions/actions/workflows/node.js.yml/badge.svg)](https://github.com/viteplus/versions/actions/workflows/node.js.yml)
7
+ [![CI](https://github.com/viteplus/versions/actions/workflows/ci.yml/badge.svg)](https://github.com/viteplus/versions/actions/workflows/ci.yml)
7
8
  [![Discord](https://img.shields.io/discord/1422908712116420659?logo=Discord&label=Discord)](https://discord.gg/6vgFhJTEGn)
8
9
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/viteplus/versions)
9
10
 
10
- @viteplus/versions is a powerful VitePress plugin that enables versioned documentation with built-in localization support,
11
- seamless navigation between versions, and intelligent URL routing.
11
+ A VitePress plugin for versioned documentation. Call `defineVersionedConfig` instead of VitePress's
12
+ `defineConfig` and it manages versioned routes, a per-version sidebar and navigation, and a `VersionSwitcher`
13
+ component - so a single site can serve your current docs alongside frozen copies of every previous version.
12
14
 
13
- ## ✨ Features
15
+ It is designed for documentation that evolves across releases, with version-aware localization, automatic URL
16
+ rewriting, and per-version configuration that lets each version keep its own navigation. It builds on the API
17
+ pioneered by [vitepress-versioning-plugin](https://github.com/IMB11/vitepress-versioning-plugin) and supports
18
+ VitePress v1.6.4 and the v2.x line.
14
19
 
15
- - **Version Management**: Effortlessly manage multiple documentation versions
16
- - **Localization**: Full multi-language support with version-aware localization
17
- - **Smart URL Routing**: Automatic path rewriting for clean, predictable URLs
18
- - **Version Switcher**: Built-in component for navigating between versions
19
- - **Flexible Configuration**: Customize navigation, sidebar, and URL structures per version/locale
20
- - **VitePress**: support 2.0.0-alpha.12
20
+ ## Key Features
21
21
 
22
- ## 📦 Installation
22
+ - **Versioned routes**: serve the current docs from `src/` at the root and each `archive/` subfolder as a frozen, separately-routed version.
23
+ - **Per-version navigation**: give every version its own nav and sidebar, or share one configuration across all of them.
24
+ - **Version switcher**: a built-in `VersionSwitcher` component that lists every version and switches between them.
25
+ - **Version-aware localization**: full multi-language support, with locale and version combined into clean URLs.
26
+ - **Smart URL rewriting**: automatic, predictable paths, customizable through a `rewritesHook`.
27
+ - **Drop-in**: wraps VitePress's config and keeps every native VitePress feature.
28
+
29
+ ## Installation
23
30
 
24
31
  ```bash
25
32
  npm install @viteplus/versions
26
33
  # or
27
- yarn add @viteplus/versions
28
- # or
29
34
  pnpm add @viteplus/versions
35
+ # or
36
+ yarn add @viteplus/versions
30
37
  ```
31
38
 
32
- ## 🚀 Quick Start
39
+ @viteplus/versions requires Node.js 20 or later and works with VitePress v1.6.4 and the v2.x line.
33
40
 
34
- 1. Create a VitePress project
35
- 2. Install @viteplus/versions
36
- 3. Configure your documentation using `defineVersionedConfig`
41
+ ## Quick start
37
42
 
38
43
  ```ts
39
44
  // .vitepress/config.ts
40
45
  import { defineVersionedConfig } from '@viteplus/versions';
41
46
 
42
47
  export default defineVersionedConfig({
43
- title: 'My Project Documentation',
44
- description: 'Documentation with version control',
45
-
46
- // Version configuration
47
- versionsConfig: {
48
- current: 'v2.0.0',
49
- versionSwitcher: {
50
- text: 'Version',
51
- includeCurrentVersion: true
48
+ title: 'My Project Documentation',
49
+ description: 'Documentation with version control',
50
+ versionsConfig: {
51
+ current: 'v2.0.0',
52
+ versionSwitcher: {
53
+ text: 'Version',
54
+ includeCurrentVersion: true
55
+ }
56
+ },
57
+ themeConfig: {
58
+ nav: [
59
+ { text: 'Guide', link: '/guide/' },
60
+ { component: 'VersionSwitcher' }
61
+ ]
52
62
  }
53
- },
54
-
55
- // Standard VitePress configuration
56
- themeConfig: {
57
- nav: [
58
- { text: 'Guide', link: '/guide/' },
59
- { component: 'VersionSwitcher' }
60
- ],
61
- // ...
62
- }
63
63
  });
64
64
  ```
65
65
 
66
- ## 📂 Project Structure
66
+ Current-version content lives in `docs/src` and is served at the site root; each subfolder of `docs/archive`
67
+ becomes a frozen version. `defineVersionedConfig` wires the routing - you do not set `srcDir` yourself.
68
+
69
+ ## Theme setup
70
+
71
+ Register the `VersionSwitcher` component in your theme so it can be placed in the nav or used directly.
72
+
73
+ ```ts
74
+ // .vitepress/theme/index.ts
75
+ import DefaultTheme from 'vitepress/theme';
76
+ import VersionSwitcher from '@viteplus/versions/components/version-switcher.component.vue';
77
+
78
+ export default {
79
+ extends: DefaultTheme,
80
+ enhanceApp({ app }) {
81
+ app.component('VersionSwitcher', VersionSwitcher);
82
+ }
83
+ };
84
+ ```
85
+
86
+ ## Project structure
67
87
 
68
88
  ```text
69
89
  docs/
70
90
  ├── .vitepress/
71
91
  │ └── config.ts
72
- ├── src/ // Current version docs
73
- │ ├── en/ // English (default locale)
74
- │ │ ├── index.md
75
- │ │ └── guide/
76
- │ └── de/ // German locale
77
- │ ├── index.md
78
- │ └── guide/
79
- └── archive/ // Archived versions
80
- └── v1.0/
81
- ├── en/
82
- │ ├── index.md
83
- │ └── guide/
84
- └── de/
85
- ├── index.md
86
- └── guide/
87
-
92
+ ├── src/ // current version content (served at the root)
93
+ │ ├── index.md
94
+ │ └── guide/
95
+ └── archive/ // archived versions (each subfolder is one frozen version)
96
+ └── v1.0.x/
97
+ ├── index.md
98
+ └── guide/
88
99
  ```
89
100
 
90
- ## 🌐 Localization Support
101
+ ## Localization
102
+
103
+ Add locale subfolders under `src` and each `archive/<version>`; the default URL layout is `locale/version/source`.
91
104
 
92
105
  ```ts
93
106
  export default defineVersionedConfig({
94
- // ...
95
- locales: {
96
- root: {
97
- lang: 'en',
98
- label: 'English',
99
- themeConfig: {
100
- nav: [
101
- { text: 'Home', link: '/' },
102
- { text: 'Guide', link: '/guide/' }
103
- ]
104
- }
105
- },
106
- de: {
107
- lang: 'de',
108
- label: 'Deutsch',
109
- themeConfig: {
110
- nav: [
111
- { text: 'Startseite', link: '/' },
112
- { text: 'Anleitung', link: '/guide/' }
113
- ]
114
- }
107
+ locales: {
108
+ root: { lang: 'en', label: 'English' },
109
+ de: { lang: 'de', label: 'Deutsch' }
115
110
  }
116
- }
117
111
  });
118
-
119
112
  ```
120
113
 
121
- ## 🔄 Version-Specific Navigation
114
+ ## Version-specific navigation
115
+
116
+ `nav` and `sidebar` each accept an array (shared by every version) or an object keyed by version, where `root`
117
+ is the current version. Version-specific entries are self-contained and do not inherit from `root`.
122
118
 
123
119
  ```ts
124
120
  export default defineVersionedConfig({
125
- themeConfig: {
126
- nav: {
127
- // Default navigation for all versions
128
- root: [
129
- { text: 'Home', link: '/' },
130
- { text: 'Guide', link: '/guide/' }
131
- ],
132
-
133
- // Navigation only for v1.0
134
- 'v1.0': [
135
- { text: 'Home', link: '/' },
136
- { text: 'Legacy API', link: '/legacy-api/' }
137
- ]
121
+ themeConfig: {
122
+ nav: {
123
+ // Default navigation for the current version
124
+ root: [
125
+ { text: 'Home', link: '/' },
126
+ { text: 'Guide', link: '/guide/' }
127
+ ],
128
+ // Navigation only for v1.0.x
129
+ 'v1.0.x': [
130
+ { text: 'Home', link: '/' },
131
+ { text: 'Legacy API', link: '/legacy-api/' }
132
+ ]
133
+ }
138
134
  }
139
- }
140
135
  });
141
-
142
136
  ```
143
137
 
144
- ## 🛠️ Custom URL Structure
138
+ ## Custom URL structure
139
+
140
+ Control how source paths map to URLs with `rewritesHook`.
145
141
 
146
142
  ```ts
147
143
  export default defineVersionedConfig({
148
- versionsConfig: {
149
- // ...
150
- hooks: {
151
- rewritesHook: (source, version, locale) => {
152
- // Custom URL structure (version first, then locale)
153
- return `${version}/${locale}/${source}`;
154
- }
144
+ versionsConfig: {
145
+ hooks: {
146
+ // version first, then locale
147
+ rewritesHook: (source, version, locale) => `${version}/${locale}/${source}`
148
+ }
155
149
  }
156
- }
157
150
  });
158
151
  ```
159
152
 
160
- ## 📚 Documentation
161
-
162
- For comprehensive guides and reference, check our [documentation](https://viteplus.github.io/versions/).
163
-
164
- - [Localization](https://viteplus.github.io/versions//guide/locales.html)
165
- - [URL Path Rewrites](https://viteplus.github.io/versions//guide/rewrites.html)
166
- - [Version Switcher](https://viteplus.github.io/versions//guide/switcher.html)
167
- - [Configuration Guide](https://viteplus.github.io/versions//guide/configuration.html)
153
+ ## Documentation
168
154
 
169
- ## 🤝 Contributing
155
+ Full guides and the configuration reference live at
156
+ **[viteplus.github.io/versions](https://viteplus.github.io/versions/)**.
170
157
 
171
- We welcome contributions! Please see our [contributing guidelines](CONTRIBUTING.md) for details.
158
+ ## Contributing
172
159
 
173
- ## 📄 License
160
+ Contributions are welcome! Open an [issue](https://github.com/viteplus/versions/issues) or a pull request on
161
+ GitHub. See the [contributing guidelines](CONTRIBUTING.md) for setup and conventions.
174
162
 
175
- This project is licensed under the [MIT License](LICENSE).
163
+ ## Links
176
164
 
177
- ## 💖 Acknowledgements
165
+ [Documentation](https://viteplus.github.io/versions/),
166
+ [GitHub Repository](https://github.com/viteplus/versions),
167
+ [Issue Tracker](https://github.com/viteplus/versions/issues),
168
+ [npm Package](https://www.npmjs.com/package/@viteplus/versions)
178
169
 
179
- - [VitePress](https://vitepress.dev/) - The amazing static site generator this plugin extends
180
- - [Vue.js](https://vuejs.org/) - The progressive JavaScript framework
181
- - [Vite](https://vitejs.dev/) - Next generation frontend tooling
182
- - `@IMB11` - for the original vitepress-versioning-plugin
170
+ ## License
183
171
 
184
- Made with ❤️ by the @viteplus team
172
+ This project is licensed under the Mozilla Public License 2.0 - see the [LICENSE](LICENSE) file for details.