Commit 9bb6dc2
fix(docs): resolve relative Card hrefs from splat route (#160)
TanStack Router cannot resolve relative `to` paths (e.g. `./quickstart`)
from within a catch-all splat route (/docs/$) — it outputs the current
page URL unchanged, so every Card link on /docs/zh appeared to navigate
nowhere.
Added `FumadocsLink` wrapper in `__root.tsx` that intercepts the `href`
prop before it reaches TanStack Router: if the href starts with `./` or
`../`, it is resolved against `window.location.pathname` (the current URL)
using the WHATWG URL parser, then passed as an absolute path to the
TanStack Router `Link`. Absolute and external hrefs pass through untouched.
Wire `FumadocsLink` into `<RootProvider components={{ Link: FumadocsLink }}`
so fumadocs-ui's Card, sidebar, and inline links all benefit.
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent c1dd681 commit 9bb6dc2
1 file changed
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
196 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
197 | 218 | | |
198 | 219 | | |
199 | 220 | | |
| |||
208 | 229 | | |
209 | 230 | | |
210 | 231 | | |
| 232 | + | |
211 | 233 | | |
212 | 234 | | |
213 | 235 | | |
| |||
0 commit comments