Skip to content

Commit 3c1a193

Browse files
authored
docs: update docs on versioning (#258)
1 parent 57f22a1 commit 3c1a193

File tree

2 files changed

+80
-101
lines changed

2 files changed

+80
-101
lines changed

advanced/user-auth/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ Here's a table that displays whether a page is shown for different combinations
8585
| `groups: []` in metadata | ❌ | ❌ | ❌ |
8686
| `groups: ['admin']` in metadata | ❌ | ❌ | ✅ |
8787
88-
<Note>Note that an empty array in the page metadata is interpreted as "No groups should see this page."</Note> */}
88+
<Note>Note that an empty array in the page metadata is interpreted as "No groups should see this page."</Note>

settings/versioning.mdx

Lines changed: 79 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -4,132 +4,111 @@ description: 'Build separate versions'
44
icon: 'square-chevron-down'
55
---
66

7+
These guides will assume `v1` pages are in a folder named `v1`, `v2` pages are in a folder named `v2`, and so on. While this method of structuring your files isn't strictly necessary, it's a great way to keep your files organized.
8+
79
## Setup
810

9-
Add `"versions": ["v2", "v1"]` to your `mint.json` file where "v1" and "v2" are the names of your versions. You can put any number of versions in this array. The first version from the array serves as the default version.
11+
Add `"versions": ["v2", "v1"]` to your `mint.json` file where `v1` and `v2` are the names of your versions. You can put any number of versions in this array. The first version from the array serves as the default version.
1012

1113
<Tip>
1214
The versions dropdown will show your versions in the order you include them in
1315
`mint.json`.
1416
</Tip>
1517

16-
## Versioning Options
17-
18-
You can add version values to anchors, groups, or individual pages.
19-
20-
### Anchors
21-
22-
You can hide an entire anchor based on a version. This is useful when you have dozens of pages you want to hide. For example, for an API reference section.
23-
24-
In `mint.json`, simply add `version` to your anchor. Anchors without a version value are shown in every version.
25-
26-
```json
27-
"anchors": [
28-
{
29-
"name": "API Reference V1",
30-
"url": "v1/api-reference",
31-
"version": "v1"
32-
},
33-
{
34-
"name": "API Reference V2",
35-
"url": "v2/api-reference",
36-
"version": "v2"
37-
},
38-
{
39-
"name": "Anchor Without a Version",
40-
"url": "example-anchor"
41-
}
42-
]
43-
```
44-
45-
You don't need to add `v1/` or `v2/` to the start of your URLs, but some customers do it to keep their doc files organized.
46-
47-
### Tabs
48-
49-
Similarly, you can version with tabs. In the `mint.json`, add `version` to the tab. Tabs without a version value are shown in every version.
18+
## Versioning Groups and Pages
5019

51-
```json
52-
"tabs": [
53-
{
54-
"name": "API Reference V1",
55-
"url": "v1/api-reference",
56-
"version": "v1"
57-
},
58-
{
59-
"name": "API Reference V2",
60-
"url": "v2/api-reference",
61-
"version": "v2"
62-
},
63-
{
64-
"name": "Tabs Without a Version",
65-
"url": "example-tab"
66-
}
67-
]
68-
```
20+
The best way to specify page versions is by adding a version value to a group in the navigation. When you specify the version of a group, that version is applied to all pages within that group.
6921

22+
You can also specify the version of a single page in the page metadata. Versions on individual pages always take precedence.
7023

71-
### Groups
72-
73-
You can version specific groups. This is useful when a few pages changed but everything else stayed the same.
74-
75-
Simply add `version` to your groups. Groups without a version value are shown in every version.
76-
77-
In the example below, pages in `Nested Group V1` only show up when `v1` docs are shown.
78-
79-
```json
24+
<CodeGroup>
25+
```json Groups (mint.json)
8026
"navigation": [
81-
{
82-
"group": "Group without a version",
83-
"pages": [
84-
{
85-
"group": "Nested Group V1",
86-
"pages": ["page-with-version", "other-page-with-version"],
87-
"version": "v1"
88-
},
89-
{
90-
"group": "Nested Group Always Shows",
91-
"pages": ["nested-page", "other-nested-page"],
92-
},
93-
"page"
94-
]
95-
}
96-
]
27+
{
28+
"group": "Getting Started",
29+
"version": "v1",
30+
"pages": [...]
31+
}
32+
],
9733
```
9834

99-
### Pages
100-
101-
You can version a single page. Add `version` to the top of your page metadata like so:
102-
103-
```md
35+
```yaml Pages (quickstart.mdx)
10436
---
105-
title: 'My page title'
106-
description: 'My page description'
107-
version: 'v1'
37+
title: 'Quickstart'
38+
version: 'v2'
10839
---
10940
```
41+
</CodeGroup>
42+
43+
<Warning>
44+
While it is possible to nest versioned groups within versioned groups, it is not recommended. If you do take this approach, the more deeply-nested version takes precedence.
45+
</Warning>
46+
47+
### Versioning Tabs and Anchors
48+
49+
You can hide a tab or anchor based on a version. This is useful if you have links that are only relevant in one version. Importantly, this does **not** apply the version to the pages within that anchor.
50+
51+
In `mint.json`, simply add `version` to your tab or anchor. Tabs and anchors without a specified version are shown in every version.
52+
53+
<CodeGroup>
54+
```json Tabs
55+
"tabs": [
56+
{
57+
"name": "API Reference V1",
58+
"url": "v1/api-reference",
59+
"version": "v1"
60+
},
61+
{
62+
"name": "API Reference V2",
63+
"url": "v2/api-reference",
64+
"version": "v2"
65+
},
66+
{
67+
"name": "Migrating from V1 to V2",
68+
"url": "https://mintlify.com/changelog/v2"
69+
},
70+
],
71+
```
11072

111-
Your navigation config in `mint.json` should include the page like normal, but the page will only show up when the correct version is selected.
73+
```json Anchors
74+
"anchors": [
75+
{
76+
"name": "API Reference V1",
77+
"url": "v1/api-reference",
78+
"version": "v1"
79+
},
80+
{
81+
"name": "API Reference V2",
82+
"url": "v2/api-reference",
83+
"version": "v2"
84+
},
85+
{
86+
"name": "Migrating from V1 to V2",
87+
"url": "https://mintlify.com/changelog/v2",
88+
"version": "v2"
89+
},
90+
],
91+
```
92+
</CodeGroup>
11293

113-
### Reusable Pages
94+
### Sharing Between Versions
11495

115-
Not _all_ content has to be hidden though! Any content without a version value shows up in every version so you never duplicate content!
96+
Not _all_ content has to be hidden though! Any content without a specified version appears in every version so you don't have to duplicate content!
11697

11798
## Troubleshooting
11899

119100
Common errors and how to fix them
120101

121102
<AccordionGroup>
122-
<Accordion title="Pages Show Up In Wrong Version" icon="circle-exclamation">
123-
You likely nested a version inside of another. For example, your group had version "v1" but your page had version "v2".
124-
125-
We do not recommend nesting versions inside of each other because it's hard to maintain your docs later.
126-
127-
</Accordion>
103+
<Accordion title="Pages Show Up In Wrong Version" icon="circle-exclamation">
104+
You likely nested a version inside of another. For example, your group had version "v1" but your page had version "v2".
128105

129-
<Accordion title="Missing Pages" icon="circle-exclamation">
106+
We do not recommend nesting versions inside of each other because it's hard to maintain your docs later.
107+
</Accordion>
130108

131-
If you add versions to your docs and the pages disappeared from your
132-
navigation, make sure you spelled the version the same as in your `versions`
133-
array in `mint.json`.
134-
</Accordion>
109+
<Accordion title="Missing Pages" icon="circle-exclamation">
110+
If you add versions to your docs and the pages disappeared from your
111+
navigation, make sure you spelled the version the same as in your `versions`
112+
array in `mint.json`.
113+
</Accordion>
135114
</AccordionGroup>

0 commit comments

Comments
 (0)