Skip to content

Commit d46bfb7

Browse files
authored
Merge pull request #7253 from layer5io/leecalcote/slices/revert
Temporary revert of the use of Slices
2 parents 376eedc + 3b49619 commit d46bfb7

File tree

10 files changed

+21
-95
lines changed

10 files changed

+21
-95
lines changed

gatsby-node.js

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ if (process.env.CI === "true") {
3636
if (page.path !== oldPage.path) {
3737
// Replace new page with old page
3838
deletePage(oldPage);
39-
page.slices = { ...DEFAULT_SLICES, ...(page.slices || {}) };
4039
createPage(page);
4140

4241
createRedirect({
@@ -52,58 +51,16 @@ if (process.env.CI === "true") {
5251

5352
const { loadRedirects } = require("./src/utils/redirects.js");
5453

55-
const DEFAULT_SLICES = {
56-
"site-header": "site-header",
57-
"site-footer": "site-footer",
58-
"cta-bottom": "cta-bottom",
59-
"cta-fullwidth": "cta-fullwidth",
60-
"cta-imageonly": "cta-imageonly",
61-
};
62-
6354
exports.createPages = async ({ actions, graphql, reporter }) => {
64-
const { createRedirect, createSlice } = actions;
55+
const { createRedirect } = actions;
6556
const redirects = loadRedirects();
6657
redirects.forEach(redirect => createRedirect(redirect)); // Handles all hardcoded ones dynamically
6758
// Create Pages
6859
const { createPage } = actions;
6960

70-
createSlice({
71-
id: "site-header",
72-
component: path.resolve("./src/slices/site-header.js"),
73-
});
74-
75-
createSlice({
76-
id: "site-footer",
77-
component: path.resolve("./src/slices/site-footer.js"),
78-
});
79-
80-
createSlice({
81-
id: "cta-bottom",
82-
component: path.resolve("./src/slices/cta-bottom.js"),
83-
});
84-
85-
createSlice({
86-
id: "cta-fullwidth",
87-
component: path.resolve("./src/slices/cta-fullwidth.js"),
88-
});
89-
90-
createSlice({
91-
id: "cta-imageonly",
92-
component: path.resolve("./src/slices/cta-imageonly.js"),
93-
});
94-
9561
const envCreatePage = (props) => {
96-
const pageConfig = { ...props };
97-
98-
if (isDevelopment) {
99-
pageConfig.defer = true;
100-
} else if (isProduction) {
101-
pageConfig.mode = "SSR";
102-
}
103-
pageConfig.slices = { ...DEFAULT_SLICES, ...(pageConfig.slices || {}) };
104-
10562
if (process.env.CI === "true") {
106-
const { path, matchPath, ...rest } = pageConfig;
63+
const { path, matchPath, ...rest } = props;
10764

10865
createRedirect({
10966
fromPath: `/${path}/`,
@@ -118,7 +75,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
11875
...rest,
11976
});
12077
}
121-
return createPage(pageConfig);
78+
return createPage(props);
12279
};
12380

12481
const blogPostTemplate = path.resolve("src/templates/blog-single.js");
@@ -555,7 +512,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
555512
});
556513

557514
const components = componentsData.map((component) => component.src.replace("/", ""));
558-
const createComponentPages = (envCreatePage, components) => {
515+
const createComponentPages = (createPage, components) => {
559516
const pageTypes = [
560517
{ suffix: "", file: "index.js" },
561518
{ suffix: "/guidance", file: "guidance.js" },
@@ -568,7 +525,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
568525
const componentPath = `./src/sections/Projects/Sistent/components/${name}/${file}`;
569526
if (fs.existsSync(path.resolve(componentPath))) {
570527
try {
571-
envCreatePage({
528+
createPage({
572529
path: pagePath,
573530
component: require.resolve(componentPath),
574531
});
@@ -582,7 +539,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
582539
});
583540
};
584541

585-
createComponentPages(envCreatePage, components);
542+
createComponentPages(createPage, components);
586543
};
587544

588545
// slug starts and ends with '/' so parts[0] and parts[-1] will be empty

root-wrapper.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from "react";
22
import { MDXProvider } from "@mdx-js/react";
33
import Code from "./src/components/CodeBlock";
4-
import { Slice } from "gatsby";
4+
import CTA_ImageOnly from "./src/components/Call-To-Actions/CTA_ImageOnly";
5+
import CTA_FullWidth from "./src/components/Call-To-Actions/CTA_FullWidth";
6+
import CTA_Bottom from "./src/components/Call-To-Actions/CTA_Bottom";
57
import { ContextWrapper } from "./context-wrapper";
68

79
// Custom image component for better CLS scores
@@ -39,9 +41,9 @@ const components = {
3941
}
4042
},
4143
img: OptimizedImage,
42-
CTA_ImageOnly: (props) => <Slice alias="cta-imageonly" sliceContext={props} />, // slice to avoid page rebuilds on CTA tweaks
43-
CTA_FullWidth: (props) => <Slice alias="cta-fullwidth" sliceContext={props} />, // slice to avoid page rebuilds on CTA tweaks
44-
CTA_Bottom: (props) => <Slice alias="cta-bottom" sliceContext={props} />
44+
CTA_ImageOnly,
45+
CTA_FullWidth,
46+
CTA_Bottom
4547
};
4648

4749
export const wrapRootElement = ({ element }) => (

src/components/layout.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@
99

1010
import React from "react";
1111
import PropTypes from "prop-types";
12-
import { Slice } from "gatsby";
1312
import ScrollToTopBtn from "./Scrolltotop-button";
13+
import Navigation from "../sections/General/Navigation";
14+
import Footer from "../sections/General/Footer";
1415
// import TopPromotionalBanner from "./TopPromotionalBanner";
1516
import { GlobalStyle } from "../sections/app.style";
17+
import CookieConsent from "./CookieConsent";
1618

1719
const Layout = ({ children }) => {
1820

1921
return (
2022
<>
2123
<GlobalStyle />
2224
{/* <TopPromotionalBanner /> */}
23-
<Slice alias="site-header" />
25+
<Navigation/>
26+
<CookieConsent />
2427
{children}
2528
<ScrollToTopBtn />
26-
<Slice alias="site-footer" />
29+
<Footer location={children.props.location} />
2730
</>
2831
);
2932
};

src/sections/General/Footer/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import Button from "../../../reusecore/Button";
77
import FooterWrapper from "./footer.style";
88
import bubblesElement from "./images/bubbles-element.svg";
99

10-
const Footer = ({ location: locationProp }) => {
10+
const Footer = ({ location }) => {
1111
var currentYear = new Date().getFullYear();
12-
const pathname = locationProp?.pathname || (typeof window !== "undefined" ? window.location.pathname : "/");
1312

1413
const getUrl = (pathname) => {
1514
// remove ".html" that results in live production build
@@ -350,7 +349,7 @@ const Footer = ({ location: locationProp }) => {
350349
<ul className="misc-links">
351350
<li className="edit-page">
352351
<a
353-
href={getUrl(pathname)}
352+
href={getUrl(location.pathname)}
354353
target="_blank"
355354
rel="noreferrer"
356355
>

src/slices/cta-bottom.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/slices/cta-fullwidth.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/slices/cta-imageonly.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/slices/site-footer.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/slices/site-header.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/templates/lite-placeholder.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import SEO from "../components/seo";
33

44
const LitePlaceholder = ({ pageContext, location }) => {
55
const {
6+
entity = "page",
67
heading = "Content disabled in lite mode",
78
description = "This route is intentionally skipped when BUILD_FULL_SITE=false.",
89
} = pageContext;

0 commit comments

Comments
 (0)