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
Copy file name to clipboardExpand all lines: fern/products/docs/pages/component-library/custom-components/reusable-markdown.mdx
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,12 @@ Keep your documentation DRY (Don't Repeat Yourself) by defining a reusable Markd
7
7
8
8
Reusable snippets work well for constants (API limits, subscription prices, version numbers), repeated warnings or notes, and standardized formatting blocks.
9
9
10
-
## Create a reusable snippet
10
+
<Steps>
11
+
<Steptitle="Create file structure">
11
12
12
-
To use reusable snippets, start by creating a new folder in your `fern` project called `snippets`. Inside the `snippets` folder, create a new Markdown file for each snippet you want to define.
13
-
14
-
For example:
13
+
Create a folder called `snippets` anywhere in your `fern` project. Inside the `snippets` folder, create a new Markdown file for each snippet you want to define.
15
14
16
-
```bash {3, 6-8}
15
+
```bashExample file structure {3, 6-8}
17
16
fern
18
17
└─ pages
19
18
└─ my-tutorial.mdx
@@ -23,16 +22,17 @@ fern
23
22
├─ peace-lily.mdx
24
23
└─ trees.mdx
25
24
```
26
-
27
-
In each snippet file, define the content you want to reuse. For example, `peace-lily.mdx` might contain:
25
+
</Step>
26
+
<Steptitle="Create snippet">
27
+
In each snippet file, define the content you want to reuse.
28
28
29
29
```mdx title="snippets/peace-lily.mdx"
30
30
<Warning> Remember to water your plant at least twice a week. </Warning>
31
31
```
32
+
</Step>
33
+
<Steptitle="Use a snippet">
32
34
33
-
## Use a reusable snippet
34
-
35
-
To use a snippet in your documentation, reference it by its file path (including the `.mdx` extension) in your content. For example, to include the `peace-lily` snippet in your content, use:
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:
36
36
37
37
<Tabs>
38
38
<Tabtitle="Markdown">
@@ -50,4 +50,16 @@ To use a snippet in your documentation, reference it by its file path (including
50
50
51
51
<Markdownsrc="/snippets/peace-lily.mdx" />
52
52
</Tab>
53
-
</Tabs>
53
+
</Tabs>
54
+
55
+
<Notetitle="File paths">
56
+
The `src` path is an absolute path that takes the `fern` folder as the root. The path is the same no matter which page you're referencing it from:
0 commit comments