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/default-components/code-blocks.mdx
+98-5Lines changed: 98 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: 'Code Blocks'
3
3
description: 'Learn how to enhance your documentation with customizable code blocks featuring syntax highlighting, line highlighting, focusing, and more.'
4
+
max-toc-depth: 2
4
5
---
5
6
6
7
Fern uses [Shiki](https://shiki.matsu.io/) for syntax highlighting in code blocks.
@@ -303,15 +304,107 @@ To disable scrolling and wrap overflow onto the next line, use the `wordWrap` pr
303
304
</Tabs>
304
305
305
306
307
+
## Deep linking
308
+
309
+
You can make specific text within code blocks clickable by defining a `links` map. This is useful for linking to documentation, API references, or related resources directly from your code examples.
310
+
311
+
The `links` property accepts a map where keys are matching patterns (exact strings or regex) and values are the URLs to link to.
const client = new PlantClient({ apiKey: "YOUR_API_KEY" });
340
+
const plant = await client.createPlant({
341
+
name: "Monstera",
342
+
species: "Monstera deliciosa"
343
+
});
344
+
```
345
+
</CodeBlock>
346
+
````
347
+
</Tab>
348
+
</Tabs>
349
+
350
+
<Note>
351
+
The `links` property uses JSON format. Each key in the map is matched exactly against text in the Code Block, and matching text becomes a clickable link to the corresponding URL.
352
+
</Note>
353
+
354
+
### Regex pattern matching
355
+
356
+
You can use regex patterns for more flexible matching. This is useful when you want to link multiple variations or patterns of text.
357
+
358
+
In the example below, the pattern `/get\\w+/` matches both `getPlant` and `getGarden`, while `/Plant(Store|Client)/` matches both `PlantStore` and `PlantClient`.
This page contains demo content for testing and showcasing various documentation components. It's hidden from navigation but can be linked to from examples.
7
+
8
+
## API client examples
9
+
10
+
### PlantClient
11
+
12
+
The `PlantClient` class is the main entry point for interacting with the Plant Store API. It handles authentication, request management, and provides access to all API endpoints.
13
+
14
+
**Constructor parameters:**
15
+
-`apiKey` (string, required): Your API authentication key
16
+
-`baseUrl` (string, optional): Custom API base URL for testing
17
+
-`timeout` (number, optional): Request timeout in milliseconds
18
+
19
+
**Example usage:**
20
+
```typescript
21
+
import { PlantClient } from"@plantstore/sdk";
22
+
23
+
const client =newPlantClient({
24
+
apiKey: "your-api-key-here"
25
+
});
26
+
```
27
+
28
+
### PlantConfig
29
+
30
+
Configuration object for customizing the Plant Store SDK behavior.
31
+
32
+
**Properties:**
33
+
-`retryAttempts` (number): Number of retry attempts for failed requests
0 commit comments