gatsby-attainlabs-cms 1.0.41 → 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.
@@ -54,6 +54,15 @@ export const TrustPilotQuery = graphql `
54
54
  }
55
55
  }
56
56
  }
57
+ allDisclaimers: allAttainLabsCmsDisclaimers {
58
+ edges {
59
+ node {
60
+ content
61
+ published
62
+ order
63
+ }
64
+ }
65
+ }
57
66
  allBlogs: allAttainLabsCmsBlogs {
58
67
  edges {
59
68
  node {
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) => {
@@ -454,10 +410,10 @@ exports.sourceNodes = async (
454
410
 
455
411
  // Blogs node creation
456
412
 
457
- const fetchBlogData = async () => {
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]}/pages.json`
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 fetchBlogData();
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-attainlabs-cms",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -76,6 +76,15 @@ export const TrustPilotQuery = graphql`
76
76
  }
77
77
  }
78
78
  }
79
+ allDisclaimers: allAttainLabsCmsDisclaimers {
80
+ edges {
81
+ node {
82
+ content
83
+ published
84
+ order
85
+ }
86
+ }
87
+ }
79
88
  allBlogs: allAttainLabsCmsBlogs {
80
89
  edges {
81
90
  node {