Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gatsby/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function branchToVersion(repo: Repo, branch: string) {
const stable = CONFIG.docs[repo].stable;
switch (branch) {
case "master":
case "main":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Good catch adding main here. I see this branchToVersion function is also present in src/shared/utils/index.ts. Let's keep our codebase DRY and consolidate them. We should export the one from src/shared/utils/index.ts and use it here.

return "dev";
case stable:
return "stable";
Expand Down
1 change: 1 addition & 0 deletions gatsby/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function getStable(doc: Repo) {
function renameVersion(version: string, stable: string | undefined) {
switch (version) {
case "master":
case "main":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Thanks for updating this. This renameVersion function is almost a mirror of convertVersionName in src/shared/utils/index.ts. To avoid future maintenance headaches, let's merge them. The version in shared/utils should probably be updated to handle an undefined stable version, and then we can use it here.

return "dev";
case stable:
return "stable";
Expand Down
2 changes: 2 additions & 0 deletions src/shared/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ function branchToVersion(repo: Repo, branch: string) {
const stable = CONFIG.docs[repo].stable;
switch (branch) {
case "master":
case "main":
return "dev";
case stable:
return "stable";
Expand Down Expand Up @@ -217,6 +218,7 @@ export const AllVersion = Object.keys(CONFIG.docs).reduce((acc, val) => {
export function convertVersionName(version: string, stable: string) {
switch (version) {
case "master":
case "main":
return "dev";
case stable:
return "stable";
Expand Down