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
3 changes: 2 additions & 1 deletion fern/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,8 @@ h1, h2, h3 {
/*** END -- LANDING PAGE STYLING ***/

/* HACK: add a slash to markdown snippet documentation (otherwise it gets parsed by CLI) */
.modify-snippet tbody tr:last-of-type td:last-of-type .line span:last-of-type:before {
.modify-snippet tbody tr:nth-child(1) td:last-of-type .line span:last-of-type:before,
.modify-snippet tbody tr:nth-child(5) td:last-of-type .line span:last-of-type:before {
content: "/";
display: inline-block;
}
Expand Down
22 changes: 22 additions & 0 deletions fern/products/docs/pages/changelog/2025-11-08.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## Parameterized markdown snippets

Reusable Markdown snippets support arbitrary parameters that can be used as variables in the snippet. This enables flexible, reusable content templates.

Create a snippet with parameter placeholders using curly braces:

```mdx fern/snippets/watering-schedule.mdx
<Warning>Remember to water your {plant} every {interval} days.</Warning>
```

Pass parameters when including the snippet:

```mdx page.mdx
<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />
```

This renders as:

<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />

Learn more about [reusable Markdown snippets](/learn/docs/writing-content/reusable-snippet).

## New Copy component for inline copyable text

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,38 @@ fern
In each snippet file, define the content you want to reuse.

```mdx title="snippets/peace-lily.mdx"
<Warning> Remember to water your plant at least twice a week. </Warning>
Peace lilies are easy to grow and relatively trouble-free.
```

Optionally, you can use parameters in your snippet:
```mdx title="snippets/watering-schedule.mdx"
<Warning>Remember to water your {plant} every {interval} days.</Warning>
```

</Step>
<Step title="Use a snippet">

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

<Tabs>
<Tab title="Markdown">
<div className="modify-snippet">
```jsx
Peace lilies are easy to grow and relatively trouble-free.

<Markdown src="/snippets/peace-lily.mdx">

They symbolize peace and prosperity.

<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3">
```
</div>

</Tab>
<Tab title="Preview">
Peace lilies are easy to grow and relatively trouble-free.

<Markdown src="/snippets/peace-lily.mdx" />

They symbolize peace and prosperity.

<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />
</Tab>
</Tabs>

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

</Steps>
2 changes: 1 addition & 1 deletion fern/snippets/peace-lily.mdx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<Warning> Remember to water your plant at least twice a week. </Warning>
Peace lilies are easy to grow and relatively trouble-free.
1 change: 1 addition & 0 deletions fern/snippets/watering-schedule.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Warning>Remember to water your {plant} every {interval} days.</Warning>
Loading