Skip to content

Commit f414157

Browse files
authored
feat: add TiDB Cloud Lake namespace and update related mappings and t… (#716)
* feat: add TiDB Cloud Lake namespace and update related mappings and tests * feat: update TiDB Cloud Lake namespace handling and related tests
1 parent 6d49cd6 commit f414157

16 files changed

Lines changed: 295 additions & 17 deletions

File tree

gatsby-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ module.exports = {
9393
{
9494
matchPath: `/:lang?/(${Object.keys(docs.docs).join(
9595
"|"
96-
)}|developer|best-practices|api|ai|releases)/(.*)`,
96+
)}|developer|best-practices|api|ai|releases|tidbcloudlake)/(.*)`,
9797
getLanguageFromPath: true,
9898
},
9999
{

gatsby/URL_MAPPING_ARCHITECTURE.md

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,33 @@ Rules are evaluated in order; the first matching rule wins.
320320

321321
---
322322

323-
### Rule 8: TiDB Index Pages with Folders
323+
### Rule 8: TiDB Cloud Lake Namespace
324+
325+
**Effect**: Maps TiDB Cloud Lake pages to the `/tidbcloudlake` namespace.
326+
327+
**Source Pattern**: `/{lang}/tidb-cloud-lake/{branch}/{...folders}/{filename}`
328+
329+
**Target Pattern**:
330+
- For `_index`: `/{lang}/tidbcloudlake/{folders}` (keeps folder structure)
331+
- For other files: `/{lang}/tidbcloudlake/{filename}` (flattens folder structure)
332+
333+
**Filename Transform**:
334+
- `ignoreIf: ["_index"]`
335+
- `conditionalTarget.keepIf: ["_index"]`
336+
337+
**Example**:
338+
- Source: `en/tidb-cloud-lake/master/_index.md`
339+
- Target: `/tidbcloudlake`
340+
- Source: `en/tidb-cloud-lake/master/tidb-cloud-lake/_index.md`
341+
- Target: `/tidbcloudlake`
342+
- Source: `en/tidb-cloud-lake/master/tidb-cloud-lake/guides/dashboards.md`
343+
- Target: `/tidbcloudlake/dashboards`
344+
345+
**Use Case**: TiDB Cloud Lake content is sourced from its own docs tree but published under a compact top-level namespace.
346+
347+
---
348+
349+
### Rule 9: TiDB Index Pages with Folders
324350

325351
**Effect**: Maps TiDB `_index.md` pages to URLs that keep their folder path, preventing multiple `_index.md` files from collapsing to the same `/tidb/{branch}` URL.
326352

@@ -340,7 +366,7 @@ Rules are evaluated in order; the first matching rule wins.
340366

341367
---
342368

343-
### Rule 9: TiDB with Branch Alias
369+
### Rule 10: TiDB with Branch Alias
344370

345371
**Effect**: Maps TiDB pages with branch aliasing (masterdev, release-*v*).
346372

@@ -365,7 +391,7 @@ Rules are evaluated in order; the first matching rule wins.
365391

366392
---
367393

368-
### Rule 10: TiDB-in-Kubernetes with Branch Alias
394+
### Rule 11: TiDB-in-Kubernetes with Branch Alias
369395

370396
**Effect**: Maps TiDB-in-Kubernetes pages with branch aliasing (maindev, release-*v*).
371397

@@ -390,7 +416,7 @@ Rules are evaluated in order; the first matching rule wins.
390416

391417
---
392418

393-
### Rule 11: Fallback Rule
419+
### Rule 12: Fallback Rule
394420

395421
**Effect**: Generic fallback for any remaining paths.
396422

@@ -505,16 +531,17 @@ Rules are evaluated in order; the first matching rule wins.
505531
506532
### Rule 6: Namespace Index Links (Direct Mapping)
507533
508-
**Effect**: Resolves namespace index links (ending with `/_index`) to namespace URLs (published as `/developer`, `/best-practices`, `/api`, `/ai`, `/tidbcloud`).
534+
**Effect**: Resolves namespace index links (ending with `/_index`) to namespace URLs (published as `/developer`, `/best-practices`, `/api`, `/ai`, `/tidbcloud`, `/tidbcloudlake`).
509535
510536
**Link Pattern**: `/{namespace}/{...folders}/_index`
511537
512538
**Target Pattern**: `/{curLang}/{namespace}/{folders}`
513539
514-
**Conditions**: `namespace = ["tidb-cloud", "develop", "best-practices", "api", "ai"]`
540+
**Conditions**: `namespace = ["tidb-cloud", "tidb-cloud-lake", "develop", "best-practices", "api", "ai"]`
515541
516542
**Namespace Transform**:
517543
- `tidb-cloud` → `tidbcloud`
544+
- `tidb-cloud-lake` → `tidbcloudlake`
518545
- `develop` → `developer`
519546
520547
**Example**:
@@ -524,29 +551,36 @@ Rules are evaluated in order; the first matching rule wins.
524551
- Link: `/best-practices/performance/_index`
525552
- Current Page: Any page
526553
- Result: `/best-practices/performance`
554+
- Link: `/tidb-cloud-lake/_index`
555+
- Current Page: Any page
556+
- Result: `/tidbcloudlake`
527557
528558
**Use Case**: Keeps namespace index links consistent with how `_index.md` pages are published.
529559
530560
---
531561
532562
### Rule 7: Namespace Links (Direct Mapping)
533563
534-
**Effect**: Resolves namespace links (`develop`, `best-practices`, `api`, `ai`, `tidb-cloud`) to namespace URLs (published as `/developer`, `/best-practices`, `/api`, `/ai`, `/tidbcloud`).
564+
**Effect**: Resolves namespace links (`develop`, `best-practices`, `api`, `ai`, `tidb-cloud`, `tidb-cloud-lake`) to namespace URLs (published as `/developer`, `/best-practices`, `/api`, `/ai`, `/tidbcloud`, `/tidbcloudlake`).
535565
536566
**Link Pattern**: `/{namespace}/{...any}/{docname}`
537567
538568
**Target Pattern**: `/{curLang}/{namespace}/{docname}`
539569
540-
**Conditions**: `namespace = ["tidb-cloud", "develop", "best-practices", "api", "ai"]`
570+
**Conditions**: `namespace = ["tidb-cloud", "tidb-cloud-lake", "develop", "best-practices", "api", "ai"]`
541571
542572
**Namespace Transform**:
543573
- `tidb-cloud` → `tidbcloud`
574+
- `tidb-cloud-lake` → `tidbcloudlake`
544575
- `develop` → `developer`
545576
546577
**Example**:
547578
- Link: `/develop/vector-search`
548579
- Current Page: Any page
549580
- Result: `/developer/vector-search`
581+
- Link: `/tidb-cloud-lake/guides/dashboards`
582+
- Current Page: Any page
583+
- Result: `/tidbcloudlake/dashboards`
550584
551585
**Use Case**: Direct links to namespace pages from any location.
552586
@@ -574,7 +608,26 @@ Rules are evaluated in order; the first matching rule wins.
574608
575609
---
576610
577-
### Rule 9: Developer/Best-Practices/API/AI Namespace Page Links (Path-Based)
611+
### Rule 9: TiDB Cloud Lake Page Links (Path-Based)
612+
613+
**Effect**: Resolves relative links from TiDB Cloud Lake pages to `/tidbcloudlake/*` URLs.
614+
615+
**Path Pattern**: `/{lang}/tidbcloudlake/{...any}`
616+
617+
**Link Pattern**: `/{...any}/{docname}`
618+
619+
**Target Pattern**: `/{lang}/tidbcloudlake/{docname}`
620+
621+
**Example**:
622+
- Current Page: `/tidbcloudlake`
623+
- Link: `/guides/dashboards`
624+
- Result: `/tidbcloudlake/dashboards`
625+
626+
**Use Case**: Relative links within TiDB Cloud Lake documentation preserve the TiDB Cloud Lake namespace.
627+
628+
---
629+
630+
### Rule 10: Developer/Best-Practices/API/AI Namespace Page Links (Path-Based)
578631
579632
**Effect**: Resolves relative links from namespace pages to TiDB stable branch URLs.
580633
@@ -598,7 +651,7 @@ Rules are evaluated in order; the first matching rule wins.
598651
599652
---
600653
601-
### Rule 10: TiDB/TiDB-in-Kubernetes Page Links (Path-Based)
654+
### Rule 11: TiDB/TiDB-in-Kubernetes Page Links (Path-Based)
602655
603656
**Effect**: Resolves relative links from TiDB or TiDB-in-Kubernetes pages, preserving branch/version.
604657
@@ -634,7 +687,7 @@ The URL mapping system provides:
634687
635688
1. **Consistent URL Structure**: Source files are mapped to clean, SEO-friendly URLs
636689
2. **Context-Aware Link Resolution**: Links are resolved based on the current page's context
637-
3. **Namespace Support**: Special namespaces (`developer`, `best-practices`, `api`, `ai`) have their own URL structure
690+
3. **Namespace Support**: Special namespaces (`developer`, `best-practices`, `api`, `ai`, `tidbcloudlake`) have their own URL structure
638691
4. **Branch Aliasing**: Internal branch names are transformed to user-friendly versions
639692
5. **Default Language Omission**: Default language (`en`) is omitted from URLs for cleaner paths
640693
6. **TOC-Driven Build**: Only files referenced in TOC files are built, reducing build size

gatsby/__tests__/get-files-from-tocs.test.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jest.mock("../toc", () => ({
99
if (tocSlug.endsWith("/TOC-tidb-cloud-starter")) {
1010
return [{ type: "nav", link: "/cloud-starter-only.md" }];
1111
}
12+
if (tocSlug.endsWith("/TOC-tidb-cloud-lake")) {
13+
return [{ type: "nav", link: "/lake-only.md" }];
14+
}
1215
return [{ type: "nav", link: "/toc-only.md" }];
1316
}),
1417
}));
@@ -132,5 +135,30 @@ describe("getFilesFromTocs TOC selection rules", () => {
132135
new Set(["toc-only", "cloud-starter-only"])
133136
);
134137
});
135-
});
136138

139+
it("tidb-cloud-lake reads its Lake TOC under master", async () => {
140+
const { getFilesFromTocs } = require("../toc-filter");
141+
142+
const graphql = jest.fn().mockResolvedValue({
143+
data: {
144+
allMdx: {
145+
nodes: [
146+
makeNode(
147+
"en/tidb-cloud-lake/master/TOC",
148+
"docs/markdown-pages/en/tidb-cloud-lake/master/TOC.md"
149+
),
150+
makeNode(
151+
"en/tidb-cloud-lake/master/TOC-tidb-cloud-lake",
152+
"docs/markdown-pages/en/tidb-cloud-lake/master/TOC-tidb-cloud-lake.md"
153+
),
154+
],
155+
},
156+
},
157+
});
158+
159+
const { tocFilesMap } = await getFilesFromTocs(graphql);
160+
expect(new Set(tocFilesMap.get("en/tidb-cloud-lake/master")!)).toEqual(
161+
new Set(["toc-only", "lake-only"])
162+
);
163+
});
164+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { TOCNamespace } from "../../src/shared/interface";
2+
import { getTOCNamespace } from "../toc-namespace";
3+
4+
describe("getTOCNamespace", () => {
5+
it("maps TiDB Cloud Lake docs to the TiDB Cloud Lake namespace", () => {
6+
expect(
7+
getTOCNamespace("en/tidb-cloud-lake/master/tidb-cloud-lake/lake-overview")
8+
).toBe(TOCNamespace.TiDBCloudLake);
9+
});
10+
11+
it("maps the TiDB Cloud Lake index page to the TiDB Cloud Lake namespace", () => {
12+
expect(
13+
getTOCNamespace("en/tidb-cloud-lake/master/tidb-cloud-lake/_index")
14+
).toBe(TOCNamespace.TiDBCloudLake);
15+
});
16+
17+
it("maps root-level TiDB Cloud Lake pages to the TiDB Cloud Lake namespace", () => {
18+
expect(getTOCNamespace("en/tidb-cloud-lake/master/_index")).toBe(
19+
TOCNamespace.TiDBCloudLake
20+
);
21+
});
22+
23+
it("keeps other TiDB stable docs in the TiDB namespace", () => {
24+
expect(getTOCNamespace("en/tidb/release-8.5/alert-rules")).toBe(
25+
TOCNamespace.TiDB
26+
);
27+
});
28+
});

gatsby/link-resolver/__tests__/link-resolver.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ describe("resolveMarkdownLink", () => {
174174
expect(result).toBe("/api");
175175
});
176176

177+
it("should resolve tidb-cloud-lake/_index links to tidbcloudlake root (en - default language omitted)", () => {
178+
const result = resolveMarkdownLink(
179+
"/tidb-cloud-lake/_index",
180+
"/en/tidb/stable/alert-rules"
181+
);
182+
expect(result).toBe("/tidbcloudlake");
183+
});
184+
177185
it("should resolve best-practices namespace links (en - default language omitted)", () => {
178186
const result = resolveMarkdownLink(
179187
"/best-practices/optimization/query-optimization",
@@ -428,6 +436,22 @@ describe("resolveMarkdownLink", () => {
428436
expect(result).toBe("/zh/tidbcloud/getting-started");
429437
});
430438

439+
it("should transform tidb-cloud-lake to tidbcloudlake (en - default language omitted)", () => {
440+
const result = resolveMarkdownLink(
441+
"/tidb-cloud-lake/guides/dashboards",
442+
"/en/tidb/stable/alert-rules"
443+
);
444+
expect(result).toBe("/tidbcloudlake/dashboards");
445+
});
446+
447+
it("should transform tidb-cloud-lake to tidbcloudlake (zh - language prefix included)", () => {
448+
const result = resolveMarkdownLink(
449+
"/tidb-cloud-lake/guides/dashboards",
450+
"/zh/tidb/stable/alert-rules"
451+
);
452+
expect(result).toBe("/zh/tidbcloudlake/dashboards");
453+
});
454+
431455
it("should not match non-namespace links", () => {
432456
const result = resolveMarkdownLink(
433457
"/other/path/to/page",
@@ -493,6 +517,24 @@ describe("resolveMarkdownLink", () => {
493517
});
494518
});
495519

520+
describe("linkMappingsByPath - tidbcloudlake pages", () => {
521+
it("should resolve links from tidbcloudlake pages (with lang)", () => {
522+
const result = resolveMarkdownLink(
523+
"/guides/dashboards",
524+
"/en/tidbcloudlake"
525+
);
526+
expect(result).toBe("/tidbcloudlake/dashboards");
527+
});
528+
529+
it("should resolve links from tidbcloudlake pages (without lang, default omitted)", () => {
530+
const result = resolveMarkdownLink(
531+
"/guides/dashboards",
532+
"/tidbcloudlake"
533+
);
534+
expect(result).toBe("/tidbcloudlake/dashboards");
535+
});
536+
});
537+
496538
describe("linkMappingsByPath - tidb pages with branch", () => {
497539
it("should resolve links from tidb pages with stable branch", () => {
498540
const result = resolveMarkdownLink(

gatsby/link-resolver/config.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,44 @@ export const defaultLinkResolverConfig: LinkResolverConfig = {
4545
// /best-practices/_index -> /best-practices
4646
// /api/_index -> /api
4747
// /ai/_index -> /ai
48+
// /tidb-cloud-lake/_index -> /tidbcloudlake
4849
{
4950
linkPattern: "/{namespace}/{...folders}/_index",
5051
targetPattern: "/{curLang}/{namespace}/{folders}",
5152
conditions: {
52-
namespace: ["tidb-cloud", "develop", "best-practices", "api", "ai"],
53+
namespace: [
54+
"tidb-cloud",
55+
"tidb-cloud-lake",
56+
"develop",
57+
"best-practices",
58+
"api",
59+
"ai",
60+
],
5361
},
5462
namespaceTransform: {
5563
"tidb-cloud": "tidbcloud",
64+
"tidb-cloud-lake": "tidbcloudlake",
5665
develop: "developer",
5766
},
5867
},
5968
// /{namespace}/{...any}/{docname} -> /{curLang}/{namespace}/{docname}
60-
// Special: tidb-cloud -> tidbcloud, develop -> developer
69+
// Special: tidb-cloud -> tidbcloud, tidb-cloud-lake -> tidbcloudlake, develop -> developer
6170
{
6271
linkPattern: "/{namespace}/{...any}/{docname}",
6372
targetPattern: "/{curLang}/{namespace}/{docname}",
6473
conditions: {
65-
namespace: ["tidb-cloud", "develop", "best-practices", "api", "ai"],
74+
namespace: [
75+
"tidb-cloud",
76+
"tidb-cloud-lake",
77+
"develop",
78+
"best-practices",
79+
"api",
80+
"ai",
81+
],
6682
},
6783
namespaceTransform: {
6884
"tidb-cloud": "tidbcloud",
85+
"tidb-cloud-lake": "tidbcloudlake",
6986
develop: "developer",
7087
},
7188
},
@@ -77,7 +94,15 @@ export const defaultLinkResolverConfig: LinkResolverConfig = {
7794
linkPattern: "/{...any}/{docname}",
7895
targetPattern: "/{lang}/tidbcloud/{docname}",
7996
},
80-
// Rule 3: developer, best-practices, api, ai namespace in tidb folder
97+
// Rule 3: tidbcloudlake pages (path-based mapping)
98+
// Current page: /{lang}/tidbcloudlake/{...any}
99+
// Link: /{...any}/{docname} -> /{lang}/tidbcloudlake/{docname}
100+
{
101+
pathPattern: "/{lang}/tidbcloudlake/{...any}",
102+
linkPattern: "/{...any}/{docname}",
103+
targetPattern: "/{lang}/tidbcloudlake/{docname}",
104+
},
105+
// Rule 4: developer, best-practices, api, ai namespace in tidb folder
81106
// Current page: /{lang}/{namespace}/{...any}
82107
// Link: /{...any}/{docname} -> /{lang}/{namespace}/{docname}
83108
{

gatsby/path/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function branchToVersion(repo: Repo, branch: string) {
9696
return branch.replace("release-", "v");
9797

9898
case Repo.tidbcloud:
99+
case Repo.tidbcloudlake:
99100
return null;
100101
}
101102
}

gatsby/toc-namespace/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ const SHARED_NAMESPACE_RULES: NamespaceRule[] = [
7272
folder: "releases",
7373
minRestLength: 1,
7474
},
75+
{
76+
namespace: TOCNamespace.TiDBCloudLake,
77+
repo: Repo.tidbcloudlake,
78+
},
7579
{
7680
namespace: TOCNamespace.TiDB,
7781
repo: Repo.tidb,

0 commit comments

Comments
 (0)