Skip to content

Commit 8134650

Browse files
authored
docs: add guide for edit docs and preview in local (#5005)
1 parent 9cc216b commit 8134650

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

CONTRIBUTING.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,58 @@
2323
- `pnpm dev`
2424
- Make changes to the code
2525
- If you ran `pnpm dev` the dev watcher will automatically rebuild the code that has changed
26-
- Changes to the docs
27-
- Be sure that internal links are written always relative to `docs` folder.
28-
E.g. `./guide/data-loading`
26+
- Editing the docs locally and previewing the changes
27+
- The documentations for all the TanStack projects are hosted on [tanstack.com](https://tanstack.com), which is a TanStack Start application (https://github.com/TanStack/tanstack.com). You need to run this app locally to preview your changes in the `TanStack/router` docs.
28+
29+
> [!NOTE]
30+
> The website fetches the doc pages from GitHub in production, and searches for them at `../router/docs` in development. Your local clone of `TanStack/router` needs to be in the same directory as the local clone of `TanStack/tanstack.com`.
31+
32+
You can follow these steps to set up the docs for local development:
33+
34+
1. Make a new directory called `tanstack`.
35+
36+
```sh
37+
mkdir tanstack
38+
```
39+
40+
2. Enter that directory and clone the [`TanStack/router`](https://github.com/TanStack/router) and [`TanStack/tanstack.com`](https://github.com/TanStack/tanstack.com) repos.
41+
42+
```sh
43+
cd tanstack
44+
git clone [email protected]:TanStack/router.git
45+
# We probably don't need all the branches and commit history
46+
# from the `tanstack.com` repo, so let's just create a shallow
47+
# clone of the latest version of the `main` branch.
48+
# Read more about shallow clones here:
49+
# https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/#user-content-shallow-clones
50+
git clone [email protected]:TanStack/tanstack.com.git --depth=1 --single-branch --branch=main
51+
```
52+
53+
> [!NOTE]
54+
> Your `tanstack` directory should look like this:
55+
>
56+
> ```
57+
> tanstack/
58+
> |
59+
> +-- router/ (<-- this directory cannot be called anything else!)
60+
> |
61+
> +-- tanstack.com/
62+
> ```
63+
64+
3. Enter the `tanstack/tanstack.com` directory, install the dependencies and run the app in dev mode:
65+
66+
```sh
67+
cd tanstack.com
68+
pnpm i
69+
# The app will run on https://localhost:3000 by default
70+
pnpm dev
71+
```
72+
73+
4. Now you can visit http://localhost:3000/router/latest/docs/framework/react/overview in the browser and see the changes you make in `tanstack/router/docs` there.
74+
75+
> [!WARNING]
76+
> You will need to update the `docs/(router or start)config.json` file (in `TanStack/router`) if you add a new documentation page!
77+
78+
You can see the whole process in the screen capture below:
79+
80+
https://github.com/fulopkovacs/form/assets/43729152/9d35a3c3-8153-4e74-9cb2-af275f7a269b

0 commit comments

Comments
 (0)