Skip to content

Commit 47fab2d

Browse files
committed
Chore: Add LitePlaceholder component for lightweight build mode
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
1 parent 614d752 commit 47fab2d

2 files changed

Lines changed: 93 additions & 4 deletions

File tree

gatsby-node.js

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
5858

5959
const envCreatePage = (props) => {
6060
if (process.env.CI === "true") {
61-
const { path, ...rest } = props;
61+
const { path, matchPath, ...rest } = props;
6262

6363
createRedirect({
6464
fromPath: `/${path}/`,
@@ -69,7 +69,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
6969

7070
return createPage({
7171
path: `${path}.html`,
72-
matchPath: path,
72+
matchPath: matchPath || path,
7373
...rest,
7474
});
7575
}
@@ -108,6 +108,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
108108

109109
const resourcePostTemplate = path.resolve("src/templates/resource-single.js");
110110
const integrationTemplate = path.resolve("src/templates/integrations.js");
111+
const LitePlaceholderTemplate = path.resolve("src/templates/lite-placeholder.js");
111112

112113
const memberBioQuery = isFullSiteBuild
113114
? `
@@ -422,7 +423,47 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
422423
});
423424

424425
if (!isFullSiteBuild) {
425-
const placeholderPages = [
426+
const litePlaceholderPages = [
427+
{
428+
path: "/community/members/__lite__",
429+
matchPath: "/community/members/*",
430+
context: {
431+
entity: "member profile",
432+
heading: "Member profiles disabled in lite mode",
433+
description:
434+
"The members collection is intentionally skipped when BUILD_FULL_SITE=false to keep local builds fast.",
435+
},
436+
},
437+
{
438+
path: "/community/members/__lite__/bio",
439+
matchPath: "/community/members/*/bio",
440+
context: {
441+
entity: "executive bio",
442+
heading: "Executive bios disabled in lite mode",
443+
description:
444+
"Executive bios rely on the members collection, which is skipped while BUILD_FULL_SITE=false.",
445+
},
446+
},
447+
{
448+
path: "/cloud-native-management/meshery/__lite__",
449+
matchPath: "/cloud-native-management/meshery/*",
450+
context: {
451+
entity: "integration",
452+
heading: "Integrations disabled in lite mode",
453+
description:
454+
"Integrations are heavy to source, so this route shows a placeholder during lightweight builds.",
455+
},
456+
},
457+
];
458+
459+
litePlaceholderPages.forEach((page) =>
460+
envCreatePage({
461+
...page,
462+
component: LitePlaceholderTemplate,
463+
})
464+
);
465+
466+
const graphqlPlaceholderPages = [
426467
{
427468
path: "/__placeholders/integration",
428469
component: integrationTemplate,
@@ -447,7 +488,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
447488
},
448489
];
449490

450-
placeholderPages.forEach((page) => envCreatePage(page));
491+
graphqlPlaceholderPages.forEach((page) => envCreatePage(page));
451492
}
452493

453494
const learnNodes = res.data.learncontent.nodes;

src/templates/lite-placeholder.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from "react";
2+
import SEO from "../components/seo";
3+
4+
const LitePlaceholder = ({ pageContext, location }) => {
5+
const {
6+
entity = "page",
7+
heading = "Content disabled in lite mode",
8+
description = "This route is intentionally skipped when BUILD_FULL_SITE=false.",
9+
} = pageContext;
10+
11+
const instructions =
12+
"Run `make site-full` (or set BUILD_FULL_SITE=true) to source the full dataset, then reload this path.";
13+
14+
return (
15+
<>
16+
<SEO title={heading} description={`${description} ${instructions}`} />
17+
<main
18+
style={{
19+
padding: "4rem 1.5rem",
20+
textAlign: "center",
21+
maxWidth: "640px",
22+
margin: "0 auto",
23+
}}
24+
>
25+
<p style={{ fontWeight: 600, textTransform: "capitalize" }}>{heading}</p>
26+
<p style={{ marginTop: "1rem", lineHeight: 1.5 }}>{description}</p>
27+
<p style={{ marginTop: "0.75rem", fontStyle: "italic" }}>{instructions}</p>
28+
{location?.pathname && (
29+
<p style={{ marginTop: "1.5rem", color: "#555" }}>
30+
Requested path: <code>{location.pathname}</code>
31+
</p>
32+
)}
33+
</main>
34+
</>
35+
);
36+
};
37+
38+
export default LitePlaceholder;
39+
40+
export const Head = ({ pageContext }) => {
41+
const { heading = "Content disabled in lite mode", description = "" } = pageContext;
42+
const instructions =
43+
"Run make site-full or set BUILD_FULL_SITE=true to include heavy collections in development.";
44+
45+
return (
46+
<SEO title={heading} description={`${description} ${instructions}`.trim()} />
47+
);
48+
};

0 commit comments

Comments
 (0)