Skip to content

Commit 55c73f6

Browse files
committed
feat: enhance cloud plan handling in gatsby-ssr.js and CloudVersionSelect
- Added CLOUD_PLAN_LABEL_STRINGS to manage cloud plan labels in CloudVersionSelect, improving clarity and maintainability. - Updated gatsby-ssr.js to utilize CLOUD_PLAN_LABEL_STRINGS for dynamic content display based on URL parameters, enhancing user experience.
1 parent 0a95b97 commit 55c73f6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

gatsby-ssr.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
export { default as wrapRootElement } from "./src/state/wrap-with-provider";
2-
import { CLOUD_PLAN_LABEL_ELEMENT_ID } from "components/Layout/VersionSelect/CloudVersionSelect";
2+
import {
3+
CLOUD_PLAN_LABEL_ELEMENT_ID,
4+
CLOUD_PLAN_LABEL_STRINGS,
5+
} from "components/Layout/VersionSelect/CloudVersionSelect";
36
import docsJson from "./docs/docs.json";
47

58
// https://github.com/gatsbyjs/gatsby/issues/1526
@@ -82,11 +85,12 @@ const redirectScript = `
8285

8386
const fulfillCloudPlanScript = `
8487
(function() {
88+
const cloudPlans = ${JSON.stringify(CLOUD_PLAN_LABEL_STRINGS)};
8589
const searchParams = new URLSearchParams(location.search);
8690
const cloudMode = searchParams.get("plan");
8791
const cloudPlanLabel = document.getElementById("${CLOUD_PLAN_LABEL_ELEMENT_ID}");
8892
if (cloudPlanLabel) {
89-
cloudPlanLabel.textContent = cloudMode;
93+
cloudPlanLabel.textContent = cloudPlans[cloudMode] || cloudPlans.dedicated;
9094
}
9195
})();
9296
`;

src/components/Layout/VersionSelect/CloudVersionSelect.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import { useEffect, useRef, useState } from "react";
1414

1515
export const CLOUD_PLAN_LABEL_ELEMENT_ID = "cloud-plan-label";
1616

17+
export const CLOUD_PLAN_LABEL_STRINGS = {
18+
dedicated: "Dedicated",
19+
starter: "Starter (formerly Serverless)",
20+
essential: "Essential",
21+
};
22+
1723
const CLOUD_VERSIONS = [
1824
{
1925
label: "Dedicated",

0 commit comments

Comments
 (0)