Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fern/products/docs/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ navigation:
path: ./pages/component-library/custom-components/reusable-markdown.mdx
- page: Custom React Components
path: ./pages/component-library/custom-components/custom-react-components.mdx
- page: Global Variables
- page: Conditionally Rendered Content
hidden: true
path: ./pages/component-library/custom-components/global-variables.mdx
path: ./pages/component-library/custom-components/conditional-rendering.mdx
- section: Customization
collapsed: true
contents:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Conditionally Rendered Content
---

You can conditionally render content based on the instance or version of the docs, in addition to the role of an authenticated user.

## Conditionally render content

### Between instances

Define instances in your `docs.yml` file:

```yaml docs.yml
instances:
- url: fern-dev.docs.buildwithfern.com
name: development
- url: fern-prod.docs.buildwithfern.com
name: production
```

```mdx conditional-rendering.mdx
<If instance={["development"]}>
This is a beta feature. It should only be available when the docs have been generated with the `development` instance.
</If>

<If instance={["production"]}>
This is a production feature. It should only be available when the docs have been generated with the `production` instance.
</If>
```

### Between versions

```mdx conditional-rendering.mdx
<If version={["v1"]}>
This is an old feature. It should only be available when the user is on the `v1` version.
</If>

<If version={["v2"]}>
This is a new feature. It should only be available when the user is on the `v2` version.
</If>
```

### Based on the role of an authenticated user

```mdx conditional-rendering.mdx
<If viewer={["admin"]}>
This is an admin feature. It should only be available when the user is an admin.
</If>
```

This file was deleted.