Commit 8f11c76
Strip locale prefix from API reference sidebar links (#755)
API reference pages under /reference/api/ are only generated for the default (English) locale because they're produced from package metadata rather than translated content. However, Starlight's i18n auto-prefixes the active locale to sidebar links (e.g. /it/reference/api/csharp/), which produces 404s for any non-default locale.
Rather than redirecting at request time, fix the source: extend the existing route-data middleware to walk the sidebar tree and rewrite hrefs that match the localized API reference pattern back to their canonical, locale-stripped path. The sidebar then never emits a link that 404s, regardless of the active locale.
Reuses stripApiReferenceLocale from src/utils/api-reference-routes (added in #754) so locale detection stays in one place.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 252e547 commit 8f11c76
1 file changed
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
25 | 35 | | |
26 | 36 | | |
27 | 37 | | |
| |||
81 | 91 | | |
82 | 92 | | |
83 | 93 | | |
| 94 | + | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
87 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
88 | 121 | | |
89 | 122 | | |
90 | 123 | | |
| |||
0 commit comments