Skip to content

Commit cbcd3e3

Browse files
authored
Clarify how product and version switchers work together (#218)
1 parent 14f81b1 commit cbcd3e3

File tree

2 files changed

+51
-23
lines changed

2 files changed

+51
-23
lines changed

fern/products/docs/pages/navigation/products.mdx

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ Each product can contain its own distinct versions, tabs, sections, pages, and A
3232
Create a `products` folder inside of your `fern` folder. To specify a product's contents and navigational structure, add a `.yml` file to the `products` folder for each product.
3333
Make sure to include the `navigation` and `tabs` properties, if applicable.
3434

35-
```bash
35+
```bash {4, 7-8}
3636
fern/
3737
├─ fern.config.json
3838
├─ generators.yml
39-
├─ docs.yml
39+
├─ docs.yml # Site-level contents and navigation
4040
└─ products/
4141
├─ ...
42-
├─ product-a.yml
43-
└─ product-b.yml
42+
├─ product-a.yml # Contents and navigation for Product A
43+
└─ product-b.yml # Contents and navigation for Product B
4444
```
4545

4646
<CodeBlocks>
@@ -92,10 +92,34 @@ The optional parameters are: `image`, `icon`, `subtitle`, `slug`, and `versions`
9292

9393
<Note>If you provide both an `image` and an `icon`, the `image` will take precedence.</Note>
9494

95-
<Accordion title='Setting up Versioned Products'>
96-
Products can be versioned or unversioned. The following is an example of how more complex products might be organized:
95+
The below example is a `docs.yml` configuration for a site with two products, Product A and Product B.
9796

98-
```bash
97+
<CodeBlock title="docs.yml">
98+
```yaml {2-3, 8-9}
99+
products:
100+
- display-name: Product A
101+
path: ./products/product-a.yml
102+
icon: fa-solid fa-leaf # optional
103+
slug: product-a # optional
104+
subtitle: Product A subtitle # optional
105+
106+
- display-name: Product B
107+
path: ./products/product-b/latest.yml # <-- default showing latest
108+
image: ./images/product-b.png # optional
109+
slug: product-b # optional
110+
subtitle: Product B subtitle # optional
111+
```
112+
</CodeBlock>
113+
114+
### Add versioning to your products (optional)
115+
116+
You can optionally add versions to a product. Versioned and unversioned products can live next to each other in your site. Each version of a single product has its own `yml` file.
117+
118+
In the below example, Product A is **unversioned** and Product B is **versioned**:
119+
120+
<CodeBlock>
121+
122+
```bash {8, 10-17}
99123
fern/
100124
├─ fern.config.json
101125
├─ generators.yml
@@ -104,35 +128,30 @@ The optional parameters are: `image`, `icon`, `subtitle`, `slug`, and `versions`
104128
├─ ...
105129
└─ products/
106130
├── product-a.yml # basic unversioned product
107-
├── product-b/ # unversioned product with product-specific pages
108-
│ ├─ pages/...
109-
│ └─ product-with-pages.yml
110-
└── product-c/ # versioned product
111-
├─ product-c.yml
131+
└── product-b/ # versioned product
132+
├─ product-b.yml
112133
└─ versions/
113-
├─ v1/
114-
│ ├─ v1.yml
134+
├─ latest/
135+
│ ├─ latest.yml
115136
│ └─ pages/...
116137
└─ v2/
117138
├─ v2.yml
118139
└─ pages/...
119140
```
141+
</CodeBlock>
120142

121-
For more information on setting up versions, follow our [versioning docs](/learn/docs/building-and-customizing-your-docs/versioning).
122-
</Accordion>
123-
124-
143+
The top-level `doc.yml` configuration for a Fern Docs website containing two products, one unversioned and one versioned, might look something like this:
125144

126145
<CodeBlock title="docs.yml">
127-
```yaml
146+
```yaml {2, 8, 13-17}
128147
products:
129-
- display-name: Product A
148+
- display-name: Product A # unversioned
130149
path: ./products/product-a.yml
131150
icon: fa-solid fa-leaf # optional
132151
slug: product-a # optional
133152
subtitle: Product A subtitle # optional
134153
135-
- display-name: Product B
154+
- display-name: Product B # versioned
136155
path: ./products/product-b/latest.yml # <-- default showing latest
137156
image: ./images/product-b.png # optional
138157
slug: product-b # optional
@@ -145,6 +164,8 @@ products:
145164
```
146165
</CodeBlock>
147166

167+
For more information on setting up versioned products, follow our [versioning docs](/docs/navigation/versions).
168+
148169
### Remove extra `navigation` from `docs.yml`
149170
If your `docs.yml` file includes a `navigation` field or a `tabs` field, be sure to remove. Those fields should now belong in the product-specific `.yml` files.
150171
</Steps>

fern/products/docs/pages/navigation/versions.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ Each version of your docs can contain its own distinct tabs, sections, pages, an
1414
<Steps>
1515
### Define your versions
1616

17-
Create a `versions` folder inside of your `fern` folder. TO specify the contents of each version, add a `.yml` file to the `versions` folder to define the navigational structure of that version. Make sure to include the `navigation` and `tabs` properties, if applicable.
17+
Create a `versions` folder inside of your `fern` folder. To specify the contents of each version, add a `.yml` file to the `versions` folder to define the navigational structure of that version. Make sure to include the `navigation` and `tabs` properties, if applicable.
1818

19-
```bash
19+
<CodeBlock>
20+
```bash {7-11}
2021
fern/
2122
├─ fern.config.json
2223
├─ generators.yml
@@ -29,6 +30,10 @@ fern/
2930
├─ v2-2/pages/...
3031
└─ v2-2.yml
3132
```
33+
</CodeBlock>
34+
35+
36+
Version-specific `yml` files:
3237

3338
<CodeBlocks>
3439
<CodeBlock title="versions/v2-1.yml">
@@ -73,6 +78,8 @@ tabs:
7378
</CodeBlock>
7479
</CodeBlocks>
7580
81+
<Note>You can also have multiple products, some versioned and some unversioned. For more information on setting up multiple products, follow our [product switching docs](/docs/navigation/products).</Note>
82+
7683
### Add your version configuration
7784
7885
To define a version, in `docs.yml`, add an item to the `versions` list, specifying the `display-name` and `path`.

0 commit comments

Comments
 (0)