Skip to content

Commit f1e8e61

Browse files
devin-ai-integration[bot]chdeskurdevalog
authored
Document parameterized markdown snippets feature (#1865)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Catherine Deskur <[email protected]> Co-authored-by: Devin Logan <[email protected]>
1 parent cc098ae commit f1e8e61

File tree

5 files changed

+44
-9
lines changed

5 files changed

+44
-9
lines changed

fern/assets/styles.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,8 @@ h1, h2, h3 {
10821082
/*** END -- LANDING PAGE STYLING ***/
10831083

10841084
/* HACK: add a slash to markdown snippet documentation (otherwise it gets parsed by CLI) */
1085-
.modify-snippet tbody tr:last-of-type td:last-of-type .line span:last-of-type:before {
1085+
.modify-snippet tbody tr:nth-child(1) td:last-of-type .line span:last-of-type:before,
1086+
.modify-snippet tbody tr:nth-child(5) td:last-of-type .line span:last-of-type:before {
10861087
content: "/";
10871088
display: inline-block;
10881089
}

fern/products/docs/pages/changelog/2025-11-08.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## Parameterized markdown snippets
2+
3+
Reusable Markdown snippets support arbitrary parameters that can be used as variables in the snippet. This enables flexible, reusable content templates.
4+
5+
Create a snippet with parameter placeholders using curly braces:
6+
7+
```mdx fern/snippets/watering-schedule.mdx
8+
<Warning>Remember to water your {plant} every {interval} days.</Warning>
9+
```
10+
11+
Pass parameters when including the snippet:
12+
13+
```mdx page.mdx
14+
<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />
15+
```
16+
17+
This renders as:
18+
19+
<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />
20+
21+
Learn more about [reusable Markdown snippets](/learn/docs/writing-content/reusable-snippet).
22+
123
## New Copy component for inline copyable text
224

325
The `<Copy>` component makes text copyable with a single click. Use it inline to allow readers to quickly copy version numbers, commands, API keys, or other text snippets without selecting and copying manually.

fern/products/docs/pages/component-library/custom-components/reusable-markdown.mdx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,38 @@ fern
2727
In each snippet file, define the content you want to reuse.
2828

2929
```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.
3131
```
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+
3238
</Step>
3339
<Step title="Use a snippet">
3440

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:
3642

3743
<Tabs>
3844
<Tab title="Markdown">
3945
<div className="modify-snippet">
4046
```jsx
41-
Peace lilies are easy to grow and relatively trouble-free.
42-
4347
<Markdown src="/snippets/peace-lily.mdx">
48+
49+
They symbolize peace and prosperity.
50+
51+
<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3">
4452
```
4553
</div>
4654

4755
</Tab>
4856
<Tab title="Preview">
49-
Peace lilies are easy to grow and relatively trouble-free.
50-
5157
<Markdown src="/snippets/peace-lily.mdx" />
58+
59+
They symbolize peace and prosperity.
60+
61+
<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />
5262
</Tab>
5363
</Tabs>
5464

@@ -62,4 +72,5 @@ To use a snippet in your documentation, reference it by its file path (including
6272
| `fern/docs/guides/snippets/peace-lily.mdx` | `src="/docs/guides/snippets/peace-lily.mdx"` |
6373
</Note>
6474
</Step>
65-
</Steps>
75+
76+
</Steps>

fern/snippets/peace-lily.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<Warning> Remember to water your plant at least twice a week. </Warning>
1+
Peace lilies are easy to grow and relatively trouble-free.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<Warning>Remember to water your {plant} every {interval} days.</Warning>

0 commit comments

Comments
 (0)