Skip to content

Commit 51eb765

Browse files
committed
[Style Guide] Document using JSX in partials
1 parent b125bbd commit 51eb765

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/content/docs/style-guide/components/render.mdx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,37 @@ your partial requires parameters to be passed, and none are passed, we can warn
8989

9090
The way that you can access these parameters is with the `props` object, surrounded in curly braces `{}`.
9191
This is a [JavaScript expression within MDX](https://mdxjs.com/docs/using-mdx/#props).
92+
93+
## Dynamic (flexible) content in partials
94+
95+
As partials are authored in MDX, they are able to use JavaScript expressions based on the `params` passed in.
96+
97+
```mdx
98+
---
99+
params:
100+
- product
101+
---
102+
103+
Generic content.
104+
105+
{ props.product === "Magic WAN" && <p>Content specific to Magic WAN only.</p> }
106+
```
107+
108+
Within JavaScript expressions, HTML or components must be used.
109+
110+
For example, when `params={{ path: "/foo/" }} is provided:
111+
112+
```mdx
113+
---
114+
params:
115+
- path
116+
---
117+
118+
{/* ❌ - will link to the literal string "{props.path}" */}
119+
[link]({props.path})
120+
121+
{/* ✅ - will link to "/foo/"" */}
122+
<a href={props.path}>link</a>
123+
```
124+
125+
For this reason, the [`Markdown`](/style-guide/components/markdown/#example-for-variables-in-partials) component is available.

0 commit comments

Comments
 (0)