Skip to content

Commit 1f0b8c1

Browse files
committed
restructure new content
1 parent 7ffa3ed commit 1f0b8c1

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

fern/snippets/redirects.mdx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ The `redirects` object allows you to redirect traffic from one path to another.
22

33
If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include the subpath in both the source and destination paths.
44

5-
65
<CodeBlock title="docs.yml">
6+
77
```yml
88
redirects:
99
# Exact path redirects
@@ -35,11 +35,24 @@ If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include t
3535
Parameters suffixed with an asterisk (`*`) match zero or more path segments, capturing everything that follows in the URL. Use this when redirecting entire folder structures while preserving nested paths.
3636
</Info>
3737

38+
<ParamField path="source" type="string" required={true}>
39+
The incoming request path pattern.
40+
</ParamField>
41+
42+
<ParamField path="destination" type="string" required={true}>
43+
The path you want to route to. Can be an internal path (`/new-path`) or an external URL (`https://example.com`). External URLs must include the full address, including `https`.
44+
</ParamField>
45+
46+
<ParamField path="permanent" type="boolean" required={false}>
47+
`true` or `false` - default is `true`. If `true`, will use the 308 status code which instructs clients/search engines to cache the redirect forever. If `false`, will use the 307 status code which is temporary and is not cached.
48+
</ParamField>
49+
3850
### Advanced patterns
3951

40-
Fern uses [Path-to-RegExp](https://github.com/pillarjs/path-to-regexp) for pattern matching. Named capture groups can be defined with regex patterns and reused in destination URLs:
52+
You can define named capture groups with regex patterns and reuse them in destination URLs:
4153

4254
<CodeBlock title="docs.yml">
55+
4356
```yml
4457
redirects:
4558
# Match 4-digit years
@@ -56,24 +69,17 @@ redirects:
5669
```
5770
</CodeBlock>
5871

59-
**Pattern syntax:**
60-
- `:name` - Captures a single path segment
61-
- `:name*` - Captures zero or more segments
62-
- `:name(\\d+)` - Captures digits only
63-
- `:name(\\d{4})` - Captures exactly 4 digits
64-
- `{0}` - Literal character delimiter between parameters
72+
<Accordion title="Pattern syntax">
6573

66-
<ParamField path="source" type="string" required={true}>
67-
The incoming request path pattern.
68-
</ParamField>
74+
| Pattern | Description |
75+
|---------|-------------|
76+
| `:name` | Captures a single path segment |
77+
| `:name*` | Captures zero or more segments |
78+
| `:name(\\d+)` | Captures digits only |
79+
| `:name(\\d{4})` | Captures exactly 4 digits |
80+
| `{0}` | Literal character delimiter between parameters |
6981

70-
<ParamField path="destination" type="string" required={true}>
71-
The path you want to route to. Can be an internal path (`/new-path`) or an external URL (`https://example.com`). External URLs must include the full address, including `https`.
72-
</ParamField>
73-
74-
<ParamField path="permanent" type="boolean" required={false}>
75-
`true` or `false` - default is `true`. If `true`, will use the 308 status code which instructs clients/search engines to cache the redirect forever. If `false`, will use the 307 status code which is temporary and is not cached.
76-
</ParamField>
82+
</Accordion>
7783

7884
### Best practices
7985

0 commit comments

Comments
 (0)