Commit 3a6221a
authored
fix(landing-page): stop download function 404-shadowing localized catalog pages (#5770)
* fix(landing-page): emit localized plugins/templates/[kind] pages in production
The `[locale]/plugins/templates/[kind]` route imported `getStaticPaths`
from the sibling English `[kind]` page and re-invoked it. That cross-page
`getStaticPaths` re-export resolved to zero paths in the CI (Linux)
production build, so every `/<locale>/plugins/templates/<kind>/` URL
(deck, prototype, image, video, audio, live-artifact, hyperframes) 404'd
in production for all non-English locales — while the English routes and
the localized category index built fine. The language switcher on the
English category pages links straight into these 404s.
Derive the locale x category paths directly from PLUGIN_CATEGORIES (the
same source the English page's own getStaticPaths uses), mirroring the
self-contained `[locale]/plugins/[slug]` wrapper, so the route no longer
depends on the fragile cross-page getStaticPaths import.
* fix(landing-page): stop download function shadowing localized catalog pages
The attributed-download function `functions/[os]/[arch]/[token]/[asset].ts`
has a file-path route (`/[os]/[arch]/[token]/[asset]`) that structurally
matches ANY four-segment path. Pages Functions run before static-asset
serving, so it was intercepting the localized plugin catalog pages — e.g.
`/zh/plugins/templates/deck/` bound os=zh, arch=plugins, token=templates,
asset=deck — and returning `{"error":"download_not_found"}` (404) instead
of the real page. Every `/<locale>/plugins/templates/<kind>/` URL (the only
four-segment paths on the site) 404'd for all non-English locales, and the
language switcher on the English category pages links straight into them.
Real download URLs are minted only as `/{windows|macos|linux}/{arch}/{token}
/{asset}` (see `functions/api/attribution/mint.ts`), so gate the function on
the platform segment: anything whose first segment isn't a download platform
falls through to the static asset via `context.next()`. Download requests
are unaffected. Adds `next` to the local `PagesFunctionContext` type.
Paired with the localized `templates/[kind]` getStaticPaths fix in the same
branch, which makes those static pages exist in the first place.
---------
Co-authored-by: Joey <236967869+joeylee12629-star@users.noreply.github.com>1 parent ad89fc6 commit 3a6221a
3 files changed
Lines changed: 44 additions & 12 deletions
File tree
- apps/landing-page
- app/pages/[locale]/plugins/templates/[kind]
- functions
- [os]/[arch]/[token]
- _lib
Lines changed: 27 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
5 | 22 | | |
6 | 23 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
15 | 31 | | |
16 | 32 | | |
17 | 33 | | |
| |||
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
12 | 23 | | |
13 | 24 | | |
14 | 25 | | |
15 | 26 | | |
16 | 27 | | |
17 | | - | |
| 28 | + | |
| 29 | + | |
18 | 30 | | |
19 | 31 | | |
20 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
0 commit comments