diff --git a/gatsby/path.ts b/gatsby/path.ts index 384c22542..4a28e0e22 100644 --- a/gatsby/path.ts +++ b/gatsby/path.ts @@ -87,9 +87,10 @@ function branchToVersion(repo: Repo, branch: string) { switch (repo) { case Repo.tidb: case Repo.operator: { + const devBranch = repo === Repo.operator ? "main" : "master"; const stable = CONFIG.docs[repo].stable; switch (branch) { - case "master": + case devBranch: return "dev"; case stable: return "stable"; diff --git a/gatsby/utils.ts b/gatsby/utils.ts index 8c52ae624..fd9aed53e 100644 --- a/gatsby/utils.ts +++ b/gatsby/utils.ts @@ -21,23 +21,22 @@ export function getStable(doc: Repo) { return undefined; } -function renameVersion(version: string, stable: string | undefined) { - switch (version) { - case "master": - return "dev"; - case stable: - return "stable"; - default: - return version.replace("release-", "v"); - } -} - export function renameVersionByDoc(doc: Repo, version: string) { switch (doc) { case "tidb": case "tidb-data-migration": - case "tidb-in-kubernetes": - return renameVersion(version, getStable(doc)); + case "tidb-in-kubernetes": { + const devBranch = doc === "tidb-in-kubernetes" ? "main" : "master"; + const stable = getStable(doc); + switch (version) { + case devBranch: + return "dev"; + case stable: + return "stable"; + default: + return version.replace("release-", "v"); + } + } case "tidbcloud": return; } diff --git a/src/shared/resources.ts b/src/shared/resources.ts index fcbf68ab5..9874331a4 100644 --- a/src/shared/resources.ts +++ b/src/shared/resources.ts @@ -497,7 +497,7 @@ export const TIDB_ZH_VERSIONS = CONFIG["docs"]["tidb"]["languages"]["zh"][ export const OP_EN_VERSIONS = CONFIG["docs"]["tidb-in-kubernetes"]["languages"][ "en" -]["versions"].map((d) => convertVersionName(d, OP_EN_STABLE_VERSION)); +]["versions"].map((d) => convertVersionName(d, OP_EN_STABLE_VERSION, "tidb-in-kubernetes")); export const CLOUD_EN_VERSIONS = []; diff --git a/src/shared/utils/index.ts b/src/shared/utils/index.ts index 72beeee6c..0d3d1652b 100644 --- a/src/shared/utils/index.ts +++ b/src/shared/utils/index.ts @@ -184,9 +184,10 @@ function branchToVersion(repo: Repo, branch: string) { switch (repo) { case Repo.tidb: case Repo.operator: { + const devBranch = repo === Repo.operator ? "main" : "master"; const stable = CONFIG.docs[repo].stable; switch (branch) { - case "master": + case devBranch: return "dev"; case stable: return "stable"; @@ -214,9 +215,10 @@ export const AllVersion = Object.keys(CONFIG.docs).reduce((acc, val) => { return acc; }, {} as Record>); -export function convertVersionName(version: string, stable: string) { +export function convertVersionName(version: string, stable: string, repo?: string) { + const devBranch = repo === "tidb-in-kubernetes" ? "main" : "master"; switch (version) { - case "master": + case devBranch: return "dev"; case stable: return "stable";