gatsby-attainlabs-cms 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sliceWrapper.js +9 -0
- package/gatsby-node.js +28 -49
- package/package.json +1 -1
- package/src/sliceWrapper.tsx +9 -0
package/dist/sliceWrapper.js
CHANGED
package/gatsby-node.js
CHANGED
|
@@ -59,50 +59,6 @@ const generatePage = async (blocks, layout, isNested) => {
|
|
|
59
59
|
return await prettier.format(pageContent, { parser: "babel-ts" });
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
const generateBlogPage = async (blocks, layout, isNested) => {
|
|
63
|
-
// Validate input parameters
|
|
64
|
-
if (!Array.isArray(blocks)) {
|
|
65
|
-
throw new Error("Invalid parameters passed to createPage.");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Helper function to generate Slice components
|
|
69
|
-
const generateSlices = (blocks) => {
|
|
70
|
-
return blocks.map((b) => `<Slice alias="${b.sliceId}" />`).join("\n");
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// Generate the page content
|
|
74
|
-
const pageContent = `
|
|
75
|
-
/* This is a generated file by the gatsby-attainlabs-cms plugin. Any changes will be overwritten on the next build. */
|
|
76
|
-
import { Slice } from "gatsby";
|
|
77
|
-
import SEO from "../../../components/SEO";
|
|
78
|
-
|
|
79
|
-
export const Head = ({ pageContext }: any) => {
|
|
80
|
-
const blocks = pageContext.blocks;
|
|
81
|
-
const meta = blocks.root.props.meta;
|
|
82
|
-
return (
|
|
83
|
-
<SEO
|
|
84
|
-
title={meta ? meta.title : ""}
|
|
85
|
-
description={meta ? meta.description : ""}
|
|
86
|
-
noIndex={true}
|
|
87
|
-
/>
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const BlogPage = ({pageContext}:any ) => {
|
|
92
|
-
return (
|
|
93
|
-
<div sx={{bg:"white"}}>
|
|
94
|
-
${generateSlices(blocks)}
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export default BlogPage;
|
|
100
|
-
`;
|
|
101
|
-
|
|
102
|
-
// Format the generated code using Prettier (must await!)
|
|
103
|
-
return await prettier.format(pageContent, { parser: "babel-ts" });
|
|
104
|
-
};
|
|
105
|
-
|
|
106
62
|
const getAllBlogs = (data) => {
|
|
107
63
|
const allBlogs = [];
|
|
108
64
|
const getDatePublished = (entry) => {
|
|
@@ -183,7 +139,7 @@ exports.onPreInit = async (_, pluginOptions) => {
|
|
|
183
139
|
const org = "CuroFinTech";
|
|
184
140
|
const project = "Marketing";
|
|
185
141
|
const repo = "Attain Labs";
|
|
186
|
-
const branch = azureBranch || "
|
|
142
|
+
const branch = azureBranch || "master";
|
|
187
143
|
|
|
188
144
|
const localTargets = [
|
|
189
145
|
{
|
|
@@ -454,10 +410,10 @@ exports.sourceNodes = async (
|
|
|
454
410
|
|
|
455
411
|
// Blogs node creation
|
|
456
412
|
|
|
457
|
-
const
|
|
413
|
+
const fetchData = async () => {
|
|
458
414
|
try {
|
|
459
415
|
const response = await fetch(
|
|
460
|
-
`https://attain-finance-cms-default-rtdb.firebaseio.com/cms/brands/${brands[brand]}
|
|
416
|
+
`https://attain-finance-cms-default-rtdb.firebaseio.com/cms/brands/${brands[brand]}.json`
|
|
461
417
|
);
|
|
462
418
|
if (!response.ok) {
|
|
463
419
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
@@ -470,9 +426,9 @@ exports.sourceNodes = async (
|
|
|
470
426
|
}
|
|
471
427
|
};
|
|
472
428
|
|
|
473
|
-
const firebaseData = await
|
|
429
|
+
const firebaseData = await fetchData();
|
|
474
430
|
|
|
475
|
-
const allBlogs = getAllBlogs(firebaseData);
|
|
431
|
+
const allBlogs = getAllBlogs(firebaseData.pages);
|
|
476
432
|
|
|
477
433
|
for (const blog of allBlogs) {
|
|
478
434
|
const id = createNodeId(`attain-cms-blog-${blog.id}`);
|
|
@@ -488,8 +444,31 @@ exports.sourceNodes = async (
|
|
|
488
444
|
},
|
|
489
445
|
};
|
|
490
446
|
createNode(node);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Disclaimers Source Node
|
|
450
|
+
|
|
451
|
+
const allDisclaimers = Object.values(firebaseData.disclaimers)
|
|
452
|
+
|
|
453
|
+
for (const disclaimer of allDisclaimers) {
|
|
454
|
+
const id = createNodeId(`attain-cms-disclaimer-${disclaimer.id}`);
|
|
455
|
+
const node = {
|
|
456
|
+
...disclaimer,
|
|
457
|
+
id,
|
|
458
|
+
_id: disclaimer.id,
|
|
459
|
+
parent: null,
|
|
460
|
+
children: [],
|
|
461
|
+
internal: {
|
|
462
|
+
type: "AttainLabsCmsDisclaimers",
|
|
463
|
+
contentDigest: createContentDigest(disclaimer),
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
createNode(node);
|
|
491
467
|
}
|
|
468
|
+
|
|
469
|
+
|
|
492
470
|
};
|
|
471
|
+
|
|
493
472
|
exports.createPages = async ({ actions, store }, pluginOptions) => {
|
|
494
473
|
const { brand, environment } = pluginOptions;
|
|
495
474
|
const { createSlice, createPage } = actions;
|
package/package.json
CHANGED
package/src/sliceWrapper.tsx
CHANGED