Skip to content

Commit dd49858

Browse files
Add <If /> component to CONTRIBUTING.md (#1995)
Co-authored-by: Alexis Aguilar <[email protected]>
1 parent e140ffe commit dd49858

File tree

2 files changed

+73
-4
lines changed

2 files changed

+73
-4
lines changed

Diff for: CONTRIBUTING.md

+73-3
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,84 @@ Fallback markup to render while Clerk is loading. Default: `null`
812812

813813
### `<Include />`
814814

815-
The `<Include />` component can be used to inject the contents of another MDX file:
815+
The `<Include />` component can be used to inject the contents of another MDX file. We like to use this component to include partial files that are used in multiple pages. For example, say you have a code example that you'd like to use in multiple pages. You can create a file `code-example.mdx` in the `_partials` folder and then include it in other pages using the `<Include />` component. This way, you write the code example once and only have to maintain it in one place. The `_partials` folder uses Next.js's `_` prefix to ensure that the files are not rendered as pages.
816816

817817
```mdx
818-
{/* Render `docs/_partials/oauth-instructions.mdx` */}
818+
{/* Render `docs/_partials/code-example.mdx` */}
819819

820-
<Include src="_partials/oauth-instructions" />
820+
<Include src="_partials/code-example" />
821821
```
822822

823+
### `<If />`
824+
825+
The `<If />` component is used for conditional rendering. When the conditions are true, it displays its contents. When the conditions are false, it hides its contents. We commonly use this component to conditionally render content based on the **active SDK**. The **active SDK** is the SDK that is selected in the sidebar.
826+
827+
> [!IMPORTANT]
828+
> This component cannot be used within code blocks.
829+
830+
| Props | Type | Comment |
831+
| ----------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
832+
| `children` | `React.ReactNode` | The content that will be conditionally rendered. |
833+
| `condition?` (optional) | `boolean` | The condition that determines if the content is rendered. |
834+
| `sdk?` (optional) | `string \| string[]` | Filter the content to only display based on the passed SDK(s). For example, if the `sdk` prop is set to `['nextjs', 'react']`, the content will only be rendered if the **active SDK** is Next.js or React. |
835+
836+
Available values for the `sdk` prop:
837+
838+
| SDK | Value |
839+
| ---------------------- | --------------------- |
840+
| Next.js | "nextjs" |
841+
| React | "react" |
842+
| Javascript | "javascript-frontend" |
843+
| Chrome Extension | "chrome-extension" |
844+
| Expo | "expo" |
845+
| iOS | "ios" |
846+
| Express | "expressjs" |
847+
| Fastify | "fastify" |
848+
| React Router | "react-router" |
849+
| Remix | "remix" |
850+
| Tanstack Start | "tanstack-start" |
851+
| Go | "go" |
852+
| Astro | "astro" |
853+
| Nuxt | "nuxt" |
854+
| Vue | "vue" |
855+
| Ruby / Rails / Sinatra | "ruby" |
856+
| Python | "python" |
857+
| JS Backend SDK | "javascript-backend" |
858+
| SDK Development | "sdk-development" |
859+
| Community SDKs | "community-sdk" |
860+
861+
#### Examples
862+
863+
<details>
864+
<summary>Filtered to a single SDK</summary>
865+
866+
```mdx
867+
<If sdk="nextjs">This content will only be rendered if the active SDK is Next.js</If>
868+
```
869+
870+
</details>
871+
872+
<details>
873+
<summary>Filtered to either the Astro or React active SDK</summary>
874+
875+
```mdx
876+
<If sdk={['astro', 'react']}>This content will only be rendered if the active SDK is Astro or React</If>
877+
```
878+
879+
</details>
880+
881+
<details>
882+
<summary>Filter within a filter</summary>
883+
884+
```mdx
885+
<If sdk={['nextjs', 'remix']}>
886+
This content will only be rendered if the active SDK is Next.js or Remix.
887+
<If sdk="nextjs">This content will only be rendered if the active SDK is Next.js</If>
888+
</If>
889+
```
890+
891+
</details>
892+
823893
### Images and static assets
824894

825895
Images and static assets should be placed in the `public/` folder. To reference an image or asset in content, prefix the path with `/docs`. For example, if an image exists at `public/images/logo.png`, to render it on a page you would use the following: `![Logo](/docs/images/logo.png)`.

Diff for: docs/manifest.schema.json

-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@
169169
"chrome-extension",
170170
"expo",
171171
"ios",
172-
"nodejs",
173172
"expressjs",
174173
"fastify",
175174
"react-router",

0 commit comments

Comments
 (0)