Skip to content

Commit 0f911eb

Browse files
docs(og): pin the OG card URL's dotted final segment, and name the coupling on both sides (#13702)
`getPageImage()` in `apps/docs/lib/source.ts` appends an `image.png` marker to every Open Graph card URL. That marker is load-bearing twice, and only the first is visible from the code: the OG route slices it off to resolve the page, and its DOT is what keeps the URL out of `proxy.ts`'s locale rewriter (the matcher excludes any path containing a dot). Measured: `/og/docs/ai/agents` is rewritten to `/en/og/docs/ai/agents`, which is not a route; `/og/docs/ai/agents/x.png` is not rewritten. The marker's name is free; its dot is not. Both halves: - Cross-referencing comments on each side, each naming the other file and what breaks. - `check-docs-locale-catch-all` gains a limb asserting that the URL `getPageImage()` builds ends in a final segment containing a dot. It reads the marker AND the template that turns the array into the URL, so the assertion cannot survive as a check on a variable that no longer reaches the URL. The matcher-excludes-dots half is the condition the script already reads; it is reported in the summary, not re-asserted. Claude-Session: https://claude.ai/code/session_01Pk26oZ12t5N1hwGW1m1MgC Co-authored-by: Claude <noreply@anthropic.com>
1 parent 43fa989 commit 0f911eb

4 files changed

Lines changed: 297 additions & 12 deletions

File tree

.github/workflows/lint.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,12 +1460,23 @@ jobs:
14601460
# every type still checks, every link still resolves. The only symptom is
14611461
# a 200 where a 404 belongs, on URLs no test requests.
14621462
#
1463+
# The same matcher rule holds up a SECOND surface, gated by the same
1464+
# script: `lib/source.ts`'s `getPageImage()` appends an `image.png` marker
1465+
# to every Open Graph card URL, and that marker's DOT is the only reason
1466+
# `/og/docs/<page>/image.png` is not rewritten to `/en/og/docs/...` (not a
1467+
# route -- `app/og/` is top-level, not under `app/[lang]/`). Measured:
1468+
# `/og/docs/ai/agents` -> 404, `/og/docs/ai/agents/x.png` -> 200, so the
1469+
# marker's NAME is free and its dot is not. Rename it to anything dotless
1470+
# and every `og:image` on the site 404s at once; nothing fetches those
1471+
# URLs, so it is the same silent shape as the catch-all above.
1472+
#
14631473
# Runs its own --self-test first (via the pnpm script). Not ceremony: the
14641474
# live tree is green by construction after the fix, so a passing run over
14651475
# real data cannot distinguish a working gate from one that approves
1466-
# everything. The self-test is where every limb is observed failing, and
1467-
# where the proxy condition is observed flipping the requirement off.
1468-
- name: Docs locale catch-all rejects non-locale segments
1476+
# everything. The self-test is where every limb is observed failing --
1477+
# including the OG marker stripped of its dot -- and where the proxy
1478+
# condition is observed flipping the catch-all requirement off.
1479+
- name: Docs locale catch-all and OG card URL dot invariant
14691480
run: pnpm check:docs-locale-catch-all
14701481

14711482
# #11050 route spellings taught in prose: every /api/v1 wire-path

apps/docs/lib/source.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,31 @@ export const blog = loader({
1515
source: blogCollection.toFumadocsSource(),
1616
});
1717

18+
/**
19+
* The Open Graph card URL for a page: `/og/docs/<...page.slugs>/image.png`.
20+
*
21+
* The trailing `image.png` marker is load-bearing TWICE, and only the first is
22+
* visible from this file:
23+
*
24+
* 1. `app/og/docs/[...slug]/route.tsx` resolves the page with
25+
* `source.getPage(slug.slice(0, -1))` -- the marker is the sacrificial
26+
* segment that slice discards. Its NAME does not matter to that.
27+
* 2. Its DOT is what keeps this URL out of the locale rewriter. The matcher in
28+
* `apps/docs/proxy.ts` excludes any path containing a dot, so a dotted final
29+
* segment skips the proxy and reaches the route above. A marker WITHOUT a
30+
* dot is rewritten to `/en/og/docs/...`, which is not a route at all --
31+
* `app/og/` is top-level, not under `app/[lang]/`.
32+
*
33+
* Measured: `/og/docs/ai/agents` -> 404, `/og/docs/ai/agents/x.png` -> 200. So
34+
* the marker's name is free; the presence of a dot is everything. Rename it to
35+
* anything dotless -- or widen the proxy matcher on the other side -- and every
36+
* `og:image` on the site 404s at once, which is worse than emitting none
37+
* (crawlers fall back to scraping whatever else the page offers). Nothing
38+
* fetches these URLs, so no test, type or link check would notice.
39+
*
40+
* `pnpm check:docs-locale-catch-all` gates the dot from here; the matcher half
41+
* is commented on in `apps/docs/proxy.ts`.
42+
*/
1843
export function getPageImage(page: InferPageType<typeof source>) {
1944
const segments = [...page.slugs, 'image.png'];
2045

apps/docs/proxy.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,23 @@ export const config = {
108108
// - Next.js static files (/_next/static/*)
109109
// - Next.js image optimization (/_next/image/*)
110110
// - Favicon and other static assets
111+
//
112+
// The `.*\..*` limb -- exclude any path containing a DOT -- is load-bearing
113+
// for two surfaces beyond static assets, and neither is visible from here:
114+
//
115+
// - `apps/docs/lib/source.ts`'s `getPageImage()` appends an `image.png`
116+
// marker to every Open Graph card URL. That marker's dot is the ONLY reason
117+
// `/og/docs/<page>/image.png` is not rewritten to `/en/og/docs/...`, which
118+
// is not a route -- the `app/og/` tree is top-level, not under
119+
// `app/[lang]/`. Widening this pattern 404s every `og:image` on the site at
120+
// once, and nothing fetches those URLs, so the break is silent. Already
121+
// ruled out as a surface to widen for the same reason from the other end:
122+
// it would also 404 `/llms.txt`, `/llms-full.txt`, `/og/**` and
123+
// `/docs/**.mdx`.
124+
// - Conversely, BECAUSE dotted paths skip this proxy they reach `app/[lang]/`
125+
// with `lang` set to the literal segment (`robots.txt`, `ads.txt`), which is
126+
// why `apps/docs/lib/i18n.ts` carries the `isSupportedLanguage` guard.
127+
//
128+
// `pnpm check:docs-locale-catch-all` gates both halves.
111129
matcher: ['/((?!api|_next/static|_next/image|favicon.ico|.*\\..*).*)'],
112130
};

0 commit comments

Comments
 (0)