Commit ffbf3c3
Add short URL redirect with type prefix routing (#137)
* Add short URL redirects for content codes
Support /[code] redirects to full URLs (e.g., /b232e -> /blog/b232e/slug/).
The middleware now detects 5-character codes at the root level and
redirects to the canonical URL using a 301 permanent redirect.
- Add KIND_TO_COLLECTION mapping to code.ts
- Add getCollection() method to Code class
- Update middleware to handle root-level short code URLs
- Fix test for error message to include T kind
* Use Collection type from KIND_TO_COLLECTION mapping
Replace hardcoded type assertion with Collection type for better
maintainability and consistency with the rest of the codebase.
Co-authored-by: Justin Bennett <just-be-dev@users.noreply.github.com>
* Use KIND_TO_COLLECTION for dynamic collection pattern matching
Replace hardcoded collection names in regex with dynamic pattern
derived from KIND_TO_COLLECTION mapping.
Co-authored-by: Justin Bennett <just-be-dev@users.noreply.github.com>
* Use VALID_KINDS for dynamic error message in test
Co-authored-by: Justin Bennett <just-be-dev@users.noreply.github.com>
* Use KIND_TO_COLLECTION for dynamic short code pattern
Replace hardcoded 'brpt' regex pattern with dynamic pattern derived from KIND_TO_COLLECTION keys. This ensures the short code pattern stays in sync with the collection mappings.
Co-authored-by: Justin Bennett <just-be-dev@users.noreply.github.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Justin Bennett <just-be-dev@users.noreply.github.com>1 parent e854630 commit ffbf3c3
2 files changed
Lines changed: 66 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
8 | 34 | | |
9 | | - | |
10 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
11 | 39 | | |
12 | 40 | | |
13 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
6 | 14 | | |
7 | 15 | | |
8 | 16 | | |
| |||
155 | 163 | | |
156 | 164 | | |
157 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
158 | 173 | | |
159 | 174 | | |
160 | 175 | | |
| |||
275 | 290 | | |
276 | 291 | | |
277 | 292 | | |
278 | | - | |
| 293 | + | |
279 | 294 | | |
280 | 295 | | |
281 | 296 | | |
| |||
400 | 415 | | |
401 | 416 | | |
402 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
403 | 436 | | |
0 commit comments