Skip to content

Commit 067dba4

Browse files
authored
(docs) Clarify reference path structure, restructure some sections (#1830)
1 parent dcd9c63 commit 067dba4

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ Keep your documentation DRY (Don't Repeat Yourself) by defining a reusable Markd
77

88
Reusable snippets work well for constants (API limits, subscription prices, version numbers), repeated warnings or notes, and standardized formatting blocks.
99

10-
## Create a reusable snippet
10+
<Steps>
11+
<Step title="Create file structure">
1112

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.
1514

16-
```bash {3, 6-8}
15+
```bash Example file structure {3, 6-8}
1716
fern
1817
└─ pages
1918
└─ my-tutorial.mdx
@@ -23,16 +22,17 @@ fern
2322
├─ peace-lily.mdx
2423
└─ trees.mdx
2524
```
26-
27-
In each snippet file, define the content you want to reuse. For example, `peace-lily.mdx` might contain:
25+
</Step>
26+
<Step title="Create snippet">
27+
In each snippet file, define the content you want to reuse.
2828

2929
```mdx title="snippets/peace-lily.mdx"
3030
<Warning> Remember to water your plant at least twice a week. </Warning>
3131
```
32+
</Step>
33+
<Step title="Use a snippet">
3234

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

3737
<Tabs>
3838
<Tab title="Markdown">
@@ -50,4 +50,16 @@ To use a snippet in your documentation, reference it by its file path (including
5050

5151
<Markdown src="/snippets/peace-lily.mdx" />
5252
</Tab>
53-
</Tabs>
53+
</Tabs>
54+
55+
<Note title="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:
57+
58+
| Folder structure | Reference |
59+
| --- | --- |
60+
| `fern/snippets/peace-lily.mdx` | `src="/snippets/peace-lily.mdx"` |
61+
| `fern/docs/snippets/peace-lily.mdx` | `src="/docs/snippets/peace-lily.mdx"` |
62+
| `fern/docs/guides/snippets/peace-lily.mdx` | `src="/docs/guides/snippets/peace-lily.mdx"` |
63+
</Note>
64+
</Step>
65+
</Steps>

0 commit comments

Comments
 (0)