Skip to content

Commit 5488dfd

Browse files
authored
Condense pages on previewing docs into a single page (#2520)
1 parent 069f54f commit 5488dfd

File tree

7 files changed

+121
-173
lines changed

7 files changed

+121
-173
lines changed

.vale/styles/FernStyles/Acronyms.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,4 @@ exceptions:
102102
- SSG
103103
- REST
104104
- MDN
105+
- UUID

fern/docs.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ redirects:
298298
- source: /learn/docs/getting-started/global-configuration
299299
destination: /learn/docs/configuration/site-level-settings
300300
- source: /learn/docs/getting-started/development
301-
destination: /learn/docs/preview-publish/previewing-changes-locally
301+
destination: /learn/docs/preview-publish/preview-changes
302302
- source: /learn/docs/getting-started/publish-your-docs
303303
destination: /learn/docs/preview-publish/publishing-your-docs
304304

@@ -334,7 +334,11 @@ redirects:
334334
- source: /learn/docs/navigation/hiding-content
335335
destination: /learn/docs/customization/hiding-content
336336
- source: /learn/docs/building-and-customizing-your-docs/pull-request-preview
337-
destination: /learn/docs/preview-publish/previewing-changes-in-a-pr
337+
destination: /learn/docs/preview-publish/preview-changes
338+
- source: /learn/docs/preview-publish/previewing-changes-in-a-pr
339+
destination: /learn/docs/preview-publish/preview-changes
340+
- source: /learn/docs/preview-publish/previewing-changes-locally
341+
destination: /learn/docs/preview-publish/preview-changes
338342
- source: /learn/docs/building-and-customizing-your-docs/product-switching
339343
destination: /learn/docs/configuration/products
340344
- source: /learn/docs/navigation/products

fern/products/docs/docs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,8 @@ navigation:
162162
- section: Preview & publish
163163
collapsed: true
164164
contents:
165-
- page: Previewing changes locally
165+
- page: Preview changes
166166
path: ./pages/getting-started/preview-changes-locally.mdx
167-
- page: Previewing changes in a PR
168-
path: ./pages/getting-started/pr-preview.mdx
169167
- page: Publishing your docs
170168
path: ./pages/getting-started/publishing-your-docs.mdx
171169
- page: Setting up your domain

fern/products/docs/pages/authentication/sso.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Fern’s Single Sign-On (SSO) is an enterprise feature that lets your team secur
1414
When SSO is enabled for your organization, authenticated users of Fern can:
1515

1616
- **Use the Fern Editor**: Make edits to your docs from the browser
17-
- **Send Authenticated Preview Links** Only authenticated users can view [preview links](/learn/docs/preview-publish/previewing-changes-locally)
17+
- **Send Authenticated Preview Links** Only authenticated users can view [preview links](/learn/docs/preview-publish/preview-changes#preview-links)
1818

1919
## How it works
2020

fern/products/docs/pages/getting-started/pr-preview.mdx

Lines changed: 0 additions & 118 deletions
This file was deleted.
Lines changed: 111 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,139 @@
11
---
2-
title: "Preview changes locally"
3-
subtitle: "View and share updates to your documentation"
4-
description: "View and share updates to your documentation"
2+
title: Preview changes
3+
description: Preview changes to your docs locally or with shareable preview links.
54
---
65

7-
Fern offers two ways to preview changes to your documentation: a [local development environment](#local-development) and [unique preview links](#generate-a-preview-link).
6+
Fern offers two ways to preview documentation changes:
87

9-
## Local development
10-
11-
Fern enables you to view changes to your documentation in a locally hosted environment.
12-
13-
<Info>**Prerequisite**: Please install Node.js (version 18+) before proceeding.</Info>
14-
15-
Follow these steps to install and run the Fern CLI:
16-
17-
**Step 1**: Install the Fern CLI:
18-
19-
<CodeGroup>
20-
21-
```bash npm
22-
npm i -g fern-api
23-
```
8+
- **[Local development](#local-development)**: Fast iteration with hot reload, best for active development
9+
- **[Preview links](#preview-links)**: Shareable URLs for reviews and collaboration
2410

25-
```bash yarn
26-
yarn global add fern-api
27-
```
11+
<Info title="Prerequisites">
12+
Install the following:
13+
- Node.js version 18 or higher
14+
- [The Fern CLI](/learn/cli-api-reference/cli-reference/overview#install-fern-cli)
15+
</Info>
2816

29-
</CodeGroup>
17+
## Local development
3018

31-
**Step 2**: Navigate to the docs directory (where the `fern` folder is located) and execute the following command:
19+
[Run a local preview server](/learn/cli-api-reference/cli-reference/commands#fern-docs-dev) to view documentation changes instantly with hot reload. Offline access is available after the first online run.
3220

3321
```bash
34-
fern docs dev
22+
# Start preview server (from directory containing fern folder)
23+
fern docs dev
24+
25+
# Or use a custom port
26+
fern docs dev --port 3002
3527
```
3628

37-
A local preview of your documentation will be available at `http://localhost:3000`. The functionality is available offline if you have run local development mode online at least once.
29+
Your documentation will be available at `http://localhost:3000` (default) or the port you specified. If you attempt to run Fern on a port that's already in use, it will use the next available port.
3830

3931
<Note>
40-
Some features are disabled in the local development environment, including:
32+
Some features are disabled in local development:
4133
- Search
4234
- SEO (favicon, auto-generated meta tags, etc.)
43-
- Authentication
35+
- Authentication
4436
</Note>
4537

46-
### Custom ports
38+
## Preview links
4739

48-
By default, Fern uses port 3000. You can customize the port on which Fern runs by using the `--port` flag. For example, to run Fern on port 3002, use this command:
49-
50-
```bash
51-
fern docs dev --port 3002
52-
```
53-
54-
If you attempt to run Fern on a port that's already in use, it will use the next available port:
55-
56-
## Generate a preview link
57-
58-
Fern allows you to generate a shareable preview link that displays the current state of your docs. Each preview link is appended with a UUID and is not indexed. Currently, these links do not expire (this behavior is subject to change in the future).
59-
60-
**Usage**:
40+
Generate shareable preview URLs to review and collaborate on documentation changes before publishing. Each preview link includes a unique UUID and isn't indexed by search engines. Links don't expire.
6141

6242
```bash
6343
fern generate --docs --preview
6444
```
6545

66-
**Example**:
67-
68-
```bash
69-
fern generate --docs --preview
70-
46+
```bash Example output
7147
[docs]: Found 0 errors and 1 warnings. Run fern check --warnings to print out the warnings.
7248
[docs]: Published docs to https://fern-preview-c973a36e-337b-44f5-ab83-aab.docs.buildwithfern.com/learn
7349
┌─
7450
│ ✓ docs.example.com
7551
└─
76-
```
52+
```
53+
54+
### Automate with GitHub Actions
55+
56+
Generate preview links automatically for every pull request by adding a GitHub Actions workflow. [Add your `FERN_TOKEN` to the repository secrets](/learn/cli-api-reference/cli-reference/commands#fern-token) before using these workflows.
57+
58+
<CodeBlock title = ".github/workflows/preview-docs.yml">
59+
```yaml
60+
name: Preview Docs
61+
62+
on:
63+
pull_request
64+
65+
jobs:
66+
run:
67+
runs-on: ubuntu-latest
68+
permissions: write-all
69+
steps:
70+
- name: Checkout repository
71+
uses: actions/checkout@v4
72+
73+
- name: Install Fern
74+
run: npm install -g fern-api
75+
76+
- name: Generate preview URL
77+
env:
78+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
79+
run: |
80+
OUTPUT=$(fern generate --docs --preview 2>&1) || true
81+
echo "$OUTPUT"
82+
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
83+
echo "🌿 Preview your docs: $URL" > preview_url.txt
84+
85+
- name: Comment URL in PR
86+
uses: thollander/actions-comment-pull-request@v2.4.3
87+
with:
88+
filePath: preview_url.txt
89+
```
90+
</CodeBlock>
91+
92+
<Accordion title="For repositories that accept pull requests from forks">
93+
94+
If your repository accepts contributions from forks, use `pull_request_target` instead of `pull_request` to allow the workflow to access your `FERN_TOKEN` secret:
95+
96+
<CodeBlock title = ".github/workflows/preview-docs.yml">
97+
```yaml
98+
name: Preview Docs
99+
100+
on:
101+
pull_request_target:
102+
branches:
103+
- main
104+
105+
jobs:
106+
run:
107+
runs-on: ubuntu-latest
108+
permissions:
109+
pull-requests: write
110+
contents: read
111+
steps:
112+
- name: Checkout repository
113+
uses: actions/checkout@v4
114+
115+
- name: Install Fern
116+
run: npm install -g fern-api
117+
118+
- name: Checkout PR
119+
run: |
120+
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }}
121+
git checkout pr-${{ github.event.pull_request.number }}
122+
123+
- name: Generate preview URL
124+
env:
125+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
126+
run: |
127+
OUTPUT=$(fern generate --docs --preview 2>&1) || true
128+
echo "$OUTPUT"
129+
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
130+
echo "🌿 Preview your docs: $URL" > preview_url.txt
131+
132+
- name: Comment URL in PR
133+
uses: thollander/actions-comment-pull-request@v2.4.3
134+
with:
135+
filePath: preview_url.txt
136+
```
137+
</CodeBlock>
138+
139+
</Accordion>

fern/products/docs/pages/getting-started/quickstart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Follow this guide to get started with Fern in under 5 minutes.
183183
</Step>
184184
<Step title="Preview your docs">
185185

186-
Before publishing, [preview your changes](/docs/preview-publish/previewing-changes-locally) in your local development environment or generate shareable preview links.
186+
Before publishing, [preview your changes](/docs/preview-publish/preview-changes) in your local development environment or generate shareable preview links.
187187

188188
<Tabs>
189189
<Tab title="Local preview">

0 commit comments

Comments
 (0)