gatsby-attainlabs-cms 1.0.47 → 1.0.48

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/README.md CHANGED
@@ -58,6 +58,8 @@ module.exports = {
58
58
  brand: "Cash Money", // LendDirect | Cash Money | Heights Finance adding-puck-for-visual-code-editing
59
59
  // personalAccessToken: "optional-fallback", // not recommended, but supported
60
60
  environment: "production", // production | dev
61
+ fetch: ["blogs", "disclaimers", "faqs"] // Array of data to fetch from database
62
+ debug: false // Console logs blocks created
61
63
  },
62
64
  },
63
65
  ],
package/gatsby-node.js CHANGED
@@ -13,6 +13,8 @@ const brands = {
13
13
  "Attain Finance": "attainfinance",
14
14
  };
15
15
 
16
+ const generateSliceWrapper = () => {};
17
+
16
18
  const generatePage = async (blocks, layout, isNested) => {
17
19
  // Validate input parameters
18
20
  if (!Array.isArray(blocks)) {
@@ -62,25 +64,19 @@ const generatePage = async (blocks, layout, isNested) => {
62
64
  const getAllBlogs = (data) => {
63
65
  const allBlogs = [];
64
66
  const getDatePublished = (entry) => {
65
- const date =
66
- entry?.draft?.blocks?.root?.props?.datePublished ||
67
- entry?.blocks?.root?.props?.datePublished;
67
+ const date = entry?.blocks?.root?.props?.datePublished;
68
68
  return date ? new Date(date).getTime() : 0;
69
69
  };
70
70
 
71
71
  for (let [key, value] of Object.entries(data)) {
72
- const category =
73
- value?.draft?.blocks?.root?.props?.category ||
74
- value?.blocks?.root?.props?.category;
72
+ const category = value?.blocks?.root?.props?.category;
75
73
  if (category === "blog") {
76
74
  value = { ...value, parentFolder: value.folderUrl };
77
75
  allBlogs.push(value);
78
76
  }
79
77
  if (value.hasOwnProperty("children")) {
80
78
  for (let [childKey, childValue] of Object.entries(value["children"])) {
81
- const childCategory =
82
- childValue?.draft?.blocks?.root?.props?.category ||
83
- childValue?.blocks?.root?.props?.category;
79
+ const childCategory = childValue?.blocks?.root?.props?.category;
84
80
 
85
81
  if (childCategory === "blog") {
86
82
  childValue = { ...childValue, parentFolder: value.folderUrl };
@@ -210,6 +206,7 @@ exports.onPreInit = async (_, pluginOptions) => {
210
206
  );
211
207
  }
212
208
 
209
+ fs.writeFileSync(localPath, content);
213
210
  fs.writeFileSync(destFile, content);
214
211
  console.log(`✅ Copied and transformed ${destFile}`);
215
212
  } else {
@@ -249,7 +246,8 @@ exports.onPreInit = async (_, pluginOptions) => {
249
246
  (i) =>
250
247
  !i.isFolder &&
251
248
  i.gitObjectType === "blob" &&
252
- posix.basename(i.path) !== "config.tsx"
249
+ posix.basename(i.path) !== "config.tsx" &&
250
+ posix.basename(i.path) !== "preview.tsx"
253
251
  );
254
252
 
255
253
  console.log(`Found ${items.length} files in ${repoPath}`);
@@ -466,8 +464,12 @@ exports.sourceNodes = async (
466
464
  const firebaseData = await fetchData();
467
465
  if (fetchConfig.includes("blogs")) {
468
466
  const allBlogs = getAllBlogs(firebaseData.pages);
467
+
469
468
  for (const blog of allBlogs) {
470
469
  const id = createNodeId(`attain-cms-blog-${blog.id}`);
470
+ blog.blocks.root.props.datePublished = new Date(
471
+ blog.blocks.root.props.datePublished
472
+ );
471
473
  const node = {
472
474
  ...blog,
473
475
  id,
@@ -504,9 +506,8 @@ exports.sourceNodes = async (
504
506
  }
505
507
  }
506
508
  };
507
-
508
509
  exports.createPages = async ({ actions, store }, pluginOptions) => {
509
- const { brand, environment } = pluginOptions;
510
+ const { brand, environment, debug } = pluginOptions;
510
511
  const { createSlice, createPage } = actions;
511
512
  const siteRoot = store.getState().program.directory;
512
513
  if (environment === "dev") {
@@ -592,7 +593,7 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
592
593
  },
593
594
  });
594
595
 
595
- console.log(sliceId);
596
+ debug && console.log(sliceId);
596
597
  b["sliceId"] = sliceId;
597
598
  return b;
598
599
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-attainlabs-cms",
3
- "version": "1.0.47",
3
+ "version": "1.0.48",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",