Skip to content

Commit 673a5cf

Browse files
authored
fix: add legacy llms redirects (#1295)
Redirect patch-versioned manual LLM URLs to their major-version files. Cover v13.0.0, v12.0.0, and v11/v11.0.0 aliases with redirect tests.
1 parent 486eec5 commit 673a5cf

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

apps/docs/public/_redirects

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88
/llms/manual/llms.txt /llms.txt 307
99
/llms/manual/latest/llms.txt /llms.txt 307
1010
/llms/manual/next/llms.txt /llms.txt 307
11+
/llms/manual/v13.0.0/llms.txt /llms/manual/v13/llms.txt 307
12+
/llms/manual/v13.0.0/llms-full.txt /llms/manual/v13/llm-full.txt 307
13+
/llms/manual/v13.0.0/llms-small.txt /llms/manual/v13/llm-small.txt 307
14+
/llms/manual/v13.0.0/* /llms/manual/v13/:splat 307
15+
/llms/manual/v12.0.0/llms.txt /llms/manual/v12/llms.txt 307
16+
/llms/manual/v12.0.0/llms-full.txt /llms/manual/v12/llm-full.txt 307
17+
/llms/manual/v12.0.0/llms-small.txt /llms/manual/v12/llm-small.txt 307
18+
/llms/manual/v12.0.0/* /llms/manual/v12/:splat 307
19+
/llms/manual/v11/llms.txt /llms/manual/v12/llms.txt 307
20+
/llms/manual/v11/llms-full.txt /llms/manual/v12/llm-full.txt 307
21+
/llms/manual/v11/llms-small.txt /llms/manual/v12/llm-small.txt 307
22+
/llms/manual/v11/* /llms/manual/v12/:splat 307
23+
/llms/manual/v11.0.0/llms.txt /llms/manual/v12/llms.txt 307
24+
/llms/manual/v11.0.0/llms-full.txt /llms/manual/v12/llm-full.txt 307
25+
/llms/manual/v11.0.0/llms-small.txt /llms/manual/v12/llm-small.txt 307
26+
/llms/manual/v11.0.0/* /llms/manual/v12/:splat 307
1127
/llms/manual/latest/* /llms/manual/:splat 307
1228
/llms/manual/next/* /llms/manual/:splat 307
1329

apps/docs/scripts/test-redirects.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,44 @@ let assertRedirect = (source, destination, status) => {
3030
return entry;
3131
};
3232

33+
let assertManualLlmsVersionRedirects = (sourceVersion, destinationVersion) => {
34+
const sourcePrefix = `/llms/manual/${sourceVersion}`;
35+
const destinationPrefix = `/llms/manual/${destinationVersion}`;
36+
const index = assertRedirect(
37+
`${sourcePrefix}/llms.txt`,
38+
`${destinationPrefix}/llms.txt`,
39+
"307",
40+
);
41+
const full = assertRedirect(
42+
`${sourcePrefix}/llms-full.txt`,
43+
`${destinationPrefix}/llm-full.txt`,
44+
"307",
45+
);
46+
const small = assertRedirect(
47+
`${sourcePrefix}/llms-small.txt`,
48+
`${destinationPrefix}/llm-small.txt`,
49+
"307",
50+
);
51+
const wildcard = assertRedirect(
52+
`${sourcePrefix}/*`,
53+
`${destinationPrefix}/:splat`,
54+
"307",
55+
);
56+
57+
assert.ok(
58+
index.index < wildcard.index,
59+
`${sourcePrefix}/llms.txt must be listed before ${sourcePrefix}/*`,
60+
);
61+
assert.ok(
62+
full.index < wildcard.index,
63+
`${sourcePrefix}/llms-full.txt must be listed before ${sourcePrefix}/*`,
64+
);
65+
assert.ok(
66+
small.index < wildcard.index,
67+
`${sourcePrefix}/llms-small.txt must be listed before ${sourcePrefix}/*`,
68+
);
69+
};
70+
3371
assertRedirect("/llms/manual/llms.txt", "/llms.txt", "307");
3472
const latestAlias = assertRedirect(
3573
"/llms/manual/latest/llms.txt",
@@ -41,6 +79,10 @@ const nextAlias = assertRedirect(
4179
"/llms.txt",
4280
"307",
4381
);
82+
assertManualLlmsVersionRedirects("v13.0.0", "v13");
83+
assertManualLlmsVersionRedirects("v12.0.0", "v12");
84+
assertManualLlmsVersionRedirects("v11", "v12");
85+
assertManualLlmsVersionRedirects("v11.0.0", "v12");
4486

4587
assert.ok(
4688
latestAlias.index < findEntry("/llms/manual/latest/*").index,

0 commit comments

Comments
 (0)