Skip to content

Commit f904fe1

Browse files
authored
proposal: conditional content (#300)
1 parent ad876f5 commit f904fe1

File tree

3 files changed

+51
-81
lines changed

3 files changed

+51
-81
lines changed

fern/products/docs/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ navigation:
7979
path: ./pages/component-library/custom-components/reusable-markdown.mdx
8080
- page: Custom React Components
8181
path: ./pages/component-library/custom-components/custom-react-components.mdx
82-
- page: Global Variables
82+
- page: Conditionally Rendered Content
8383
hidden: true
84-
path: ./pages/component-library/custom-components/global-variables.mdx
84+
path: ./pages/component-library/custom-components/conditional-rendering.mdx
8585
- section: Customization
8686
collapsed: true
8787
contents:
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Conditionally Rendered Content
3+
---
4+
5+
You can conditionally render content based on the instance or version of the docs, in addition to the role of an authenticated user.
6+
7+
## Conditionally render content
8+
9+
### Between instances
10+
11+
Define instances in your `docs.yml` file:
12+
13+
```yaml docs.yml
14+
instances:
15+
- url: fern-dev.docs.buildwithfern.com
16+
name: development
17+
- url: fern-prod.docs.buildwithfern.com
18+
name: production
19+
```
20+
21+
```mdx conditional-rendering.mdx
22+
<If instance={["development"]}>
23+
This is a beta feature. It should only be available when the docs have been generated with the `development` instance.
24+
</If>
25+
26+
<If instance={["production"]}>
27+
This is a production feature. It should only be available when the docs have been generated with the `production` instance.
28+
</If>
29+
```
30+
31+
### Between versions
32+
33+
```mdx conditional-rendering.mdx
34+
<If version={["v1"]}>
35+
This is an old feature. It should only be available when the user is on the `v1` version.
36+
</If>
37+
38+
<If version={["v2"]}>
39+
This is a new feature. It should only be available when the user is on the `v2` version.
40+
</If>
41+
```
42+
43+
### Based on the role of an authenticated user
44+
45+
```mdx conditional-rendering.mdx
46+
<If viewer={["admin"]}>
47+
This is an admin feature. It should only be available when the user is an admin.
48+
</If>
49+
```

fern/products/docs/pages/component-library/custom-components/global-variables.mdx

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)