Skip to content

Commit 05bda5b

Browse files
Move parameterized snippets documentation to existing reusable snippets page
Co-Authored-By: Catherine Deskur <[email protected]>
1 parent 4651ecb commit 05bda5b

File tree

8 files changed

+43
-76
lines changed

8 files changed

+43
-76
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
## Parameterized markdown snippets
22

3-
Reusable markdown snippets can now accept 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.
44

55
Create a snippet with parameter placeholders using curly braces:
66

7-
```mdx fern/snippets/feature.mdx
8-
This feature is only available on the {plan} plan.
7+
```mdx fern/snippets/watering-schedule.mdx
8+
Water your {plant} every {interval} days.
99
```
1010

1111
Pass parameters when including the snippet:
1212

1313
```mdx page.mdx
14-
<Markdown src="/snippets/feature.mdx" plan="pro" />
14+
<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />
1515
```
1616

1717
This renders as:
1818

1919
```
20-
This feature is only available on the pro plan.
20+
Water your peace lily every 3 days.
2121
```
2222

23-
Learn more about [reusable markdown snippets](/learn/docs/content/markdown#reusable-markdown-snippets).
23+
Learn more about [reusable markdown snippets](/learn/docs/writing-content/reusable-snippets#parameterized-snippets).

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,38 @@ To use a snippet in your documentation, reference it by its file path (including
6262
| `fern/docs/guides/snippets/peace-lily.mdx` | `src="/docs/guides/snippets/peace-lily.mdx"` |
6363
</Note>
6464
</Step>
65-
</Steps>
65+
<Step title="Parameterized snippets">
66+
67+
Reusable markdown snippets support parameters that you pass as props to the Markdown component. Reference them inside the snippet with `{paramName}`.
68+
69+
Create a snippet with parameter placeholders:
70+
71+
```mdx title="snippets/watering-schedule.mdx"
72+
Water your {plant} every {interval} days.
73+
```
74+
75+
Pass parameters when including the snippet:
76+
77+
<Tabs>
78+
<Tab title="Markdown">
79+
```jsx
80+
<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />
81+
```
82+
</Tab>
83+
<Tab title="Preview">
84+
<Markdown src="/snippets/watering-schedule.mdx" plant="peace lily" interval="3" />
85+
</Tab>
86+
</Tabs>
87+
88+
You can use multiple parameters in a single snippet:
89+
90+
```mdx title="snippets/plant-care.mdx"
91+
The {plant} thrives in {light} light and prefers {temperature} temperatures.
92+
```
93+
94+
```jsx
95+
<Markdown src="/snippets/plant-care.mdx" plant="fern" light="indirect" temperature="moderate" />
96+
```
97+
98+
</Step>
99+
</Steps>

fern/products/docs/pages/component-library/writing-content/markdown.mdx

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -51,70 +51,6 @@ The value for `page` is used as the content of the top `<h1>` element of this pa
5151

5252
Fern has a built-in component library you can use in Markdown. [Explore the components.](/learn/docs/content/components/overview)
5353

54-
## Reusable markdown snippets
55-
56-
You can create reusable markdown snippets and include them in multiple pages using the `<Markdown>` component. This is useful for content that appears in multiple places, such as warnings, common instructions, or version numbers.
57-
58-
### Basic usage
59-
60-
Create a snippet file in your `fern/snippets/` folder:
61-
62-
<CodeBlock title='fern/snippets/common-warning.mdx'>
63-
```mdx
64-
<Warning>
65-
This feature is in beta and may change in future releases.
66-
</Warning>
67-
```
68-
</CodeBlock>
69-
70-
Then include it in any page using the `<Markdown>` component:
71-
72-
<CodeBlock title='page.mdx'>
73-
```mdx
74-
<Markdown src="/snippets/common-warning.mdx" />
75-
```
76-
</CodeBlock>
77-
78-
### Parameterized snippets
79-
80-
Snippets can accept arbitrary parameters that can be used as variables within the snippet content. This allows you to create flexible, reusable content templates.
81-
82-
Create a snippet with parameter placeholders using curly braces:
83-
84-
<CodeBlock title='fern/snippets/feature.mdx'>
85-
```mdx
86-
This feature is only available on the {plan} plan.
87-
```
88-
</CodeBlock>
89-
90-
Pass parameters when including the snippet:
91-
92-
<CodeBlock title='page.mdx'>
93-
```mdx
94-
<Markdown src="/snippets/feature.mdx" plan="pro" />
95-
```
96-
</CodeBlock>
97-
98-
This renders as:
99-
100-
```
101-
This feature is only available on the pro plan.
102-
```
103-
104-
You can use multiple parameters in a single snippet:
105-
106-
<CodeBlock title='fern/snippets/sdk-install.mdx'>
107-
```mdx
108-
Install the {language} SDK version {version} using {packageManager}.
109-
```
110-
</CodeBlock>
111-
112-
<CodeBlock title='page.mdx'>
113-
```mdx
114-
<Markdown src="/snippets/sdk-install.mdx" language="TypeScript" version="3.28.1" packageManager="npm" />
115-
```
116-
</CodeBlock>
117-
11854
## Links in Markdown
11955

12056
### Link target

fern/snippets/common-warning.mdx

Lines changed: 0 additions & 3 deletions
This file was deleted.

fern/snippets/feature.mdx

Lines changed: 0 additions & 1 deletion
This file was deleted.

fern/snippets/plant-care.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The {plant} thrives in {light} light and prefers {temperature} temperatures.

fern/snippets/sdk-install.mdx

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Water your {plant} every {interval} days.

0 commit comments

Comments
 (0)