You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reusable markdown snippets support arbitrary parameters that can be used as variables in the snippet. This enables flexible, reusable content templates.
3
+
Reusable Markdown snippets support arbitrary parameters that can be used as variables in the snippet. This enables flexible, reusable content templates.
4
4
5
5
Create a snippet with parameter placeholders using curly braces:
6
6
7
7
```mdx fern/snippets/watering-schedule.mdx
8
-
Water your {plant} every {interval} days.
8
+
<Warning>Remember to water your {plant} every {interval} days.</Warning>
9
9
```
10
10
11
11
Pass parameters when including the snippet:
@@ -16,8 +16,6 @@ Pass parameters when including the snippet:
Copy file name to clipboardExpand all lines: fern/products/docs/pages/component-library/custom-components/reusable-markdown.mdx
+16-39Lines changed: 16 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,28 +27,38 @@ fern
27
27
In each snippet file, define the content you want to reuse.
28
28
29
29
```mdx title="snippets/peace-lily.mdx"
30
-
<Warning> Remember to water your plant at least twice a week. </Warning>
30
+
Peace lilies are easy to grow and relatively trouble-free.
31
31
```
32
+
33
+
Optionally, you can use parameters in your snippet:
34
+
```mdx title="snippets/watering-schedule.mdx"
35
+
<Warning>Remember to water your {plant} every {interval} days.</Warning>
36
+
```
37
+
32
38
</Step>
33
39
<Steptitle="Use a snippet">
34
40
35
-
To use a snippet in your documentation, reference it by its file path (including the `.mdx` extension). For example, to include the `peace-lily`snippet from the folder structure above:
41
+
To use a snippet in your documentation, reference it by its file path (including the `.mdx` extension). If you used one or more parameters in your snippet, pass them in the snippet reference:
36
42
37
43
<Tabs>
38
44
<Tabtitle="Markdown">
39
45
<divclassName="modify-snippet">
40
46
```jsx
41
-
Peace lilies are easy to grow and relatively trouble-free.
0 commit comments