Skip to content

Commit be56283

Browse files
committed
fix: improve TOC type determination in getTidbCloudFilesFromTocs function
- Updated the logic to initialize tocType as null and added checks to handle cases where the TOC type cannot be determined. - Enhanced error logging to provide clearer insights when a TOC lacks a defined type, improving debugging and maintainability.
1 parent cf82c62 commit be56283

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gatsby/cloud-plan.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ export async function getTidbCloudFilesFromTocs(graphql: any): Promise<TocMap> {
5656

5757
// Determine TOC type based on filename
5858
const relativePath = node.parent.relativePath;
59-
let tocType: CloudPlan = "dedicated";
59+
let tocType: CloudPlan | null = null;
6060

61-
if (relativePath.includes("TOC-tidb-cloud-starter")) {
61+
if (relativePath.includes("TOC.md")) {
62+
tocType = "dedicated";
63+
} else if (relativePath.includes("TOC-tidb-cloud-starter")) {
6264
tocType = "starter";
6365
} else if (relativePath.includes("TOC-tidb-cloud-essential")) {
6466
tocType = "essential";
@@ -78,6 +80,10 @@ export async function getTidbCloudFilesFromTocs(graphql: any): Promise<TocMap> {
7880

7981
// Add files to the appropriate TOC type
8082
const entry = tidbCloudTocFilesMap.get(key)!;
83+
if (!tocType) {
84+
console.error(`TOC ${key} has no type`);
85+
return;
86+
}
8187
entry[tocType] = new Set(files);
8288

8389
console.info(`TOC ${key} (${tocType}): found ${files.length} files`);

0 commit comments

Comments
 (0)