gatsby-attainlabs-cms 1.0.43 → 1.0.45
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/gatsby-node.js +28 -24
- package/package.json +2 -2
- package/test-trust.js +0 -0
package/gatsby-node.js
CHANGED
|
@@ -28,7 +28,7 @@ const generatePage = async (blocks, layout, isNested) => {
|
|
|
28
28
|
const pageContent = `
|
|
29
29
|
/* This is a generated file by the gatsby-attainlabs-cms plugin. Any changes will be overwritten on the next build. */
|
|
30
30
|
import { Slice } from "gatsby";
|
|
31
|
-
import SEO from "../${isNested && "../"}components/SEO";
|
|
31
|
+
import SEO from "../${isNested && "../"}../cms/components/SEO";
|
|
32
32
|
|
|
33
33
|
export const Head = ({ pageContext }: any) => {
|
|
34
34
|
const blocks = pageContext.blocks;
|
|
@@ -37,7 +37,7 @@ const generatePage = async (blocks, layout, isNested) => {
|
|
|
37
37
|
<SEO
|
|
38
38
|
title={meta ? meta.title : ""}
|
|
39
39
|
description={meta ? meta.description : ""}
|
|
40
|
-
noIndex={
|
|
40
|
+
noIndex={meta ? meta.robots : ""}
|
|
41
41
|
data={blocks}
|
|
42
42
|
/>
|
|
43
43
|
);
|
|
@@ -116,9 +116,9 @@ exports.onPreInit = async (_, pluginOptions) => {
|
|
|
116
116
|
if (!pat) {
|
|
117
117
|
console.warn(
|
|
118
118
|
"⚠️ [gatsby-attainlabs-cms] No PERSONAL_ACCESS_TOKEN found. " +
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
"Set it in your project's .env file (recommended) or pass via plugin options.\n" +
|
|
120
|
+
"Example .env:\n" +
|
|
121
|
+
"PERSONAL_ACCESS_TOKEN=xxxxxxx\n"
|
|
122
122
|
);
|
|
123
123
|
return; // stop execution early
|
|
124
124
|
}
|
|
@@ -127,12 +127,12 @@ exports.onPreInit = async (_, pluginOptions) => {
|
|
|
127
127
|
if (!brand || !brands[brand]) {
|
|
128
128
|
throw new Error(
|
|
129
129
|
`[gatsby-attainlabs-cms] Invalid or missing "brand" option.\n` +
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
`You must specify one of: ${Object.keys(brands).join(", ")}\n` +
|
|
131
|
+
`Example:\n` +
|
|
132
|
+
`{\n` +
|
|
133
|
+
` resolve: "gatsby-attainlabs-cms",\n` +
|
|
134
|
+
` options: { brand: "Cash Money" }\n` +
|
|
135
|
+
`}`
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -343,9 +343,9 @@ exports.sourceNodes = async (
|
|
|
343
343
|
if (!apiKey) {
|
|
344
344
|
console.warn(
|
|
345
345
|
"⚠️ [gatsby-attainlabs-cms] No TRUSTPILOT_API_KEY found. " +
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
"Set it in your project's .env file (recommended) or pass via plugin options.\n" +
|
|
347
|
+
"Example .env:\n" +
|
|
348
|
+
"TRUSTPILOT_API_KEY=xxxxxxx\n"
|
|
349
349
|
);
|
|
350
350
|
return; // stop execution early
|
|
351
351
|
}
|
|
@@ -353,8 +353,8 @@ exports.sourceNodes = async (
|
|
|
353
353
|
if (!brand || !businessUnitId) {
|
|
354
354
|
console.warn(
|
|
355
355
|
"⚠️ [gatsby-attainlabs-cms] Invalid or missing 'brand' option for Trustpilot integration. " +
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
`Current value: '${brand}'. Supported brands: ${Object.keys(businessIds).join(", ")}. ` +
|
|
357
|
+
"Trustpilot data will not be fetched."
|
|
358
358
|
);
|
|
359
359
|
return; // stop execution early
|
|
360
360
|
}
|
|
@@ -444,10 +444,10 @@ exports.sourceNodes = async (
|
|
|
444
444
|
},
|
|
445
445
|
};
|
|
446
446
|
createNode(node);
|
|
447
|
-
}
|
|
447
|
+
}
|
|
448
448
|
|
|
449
449
|
// Disclaimers Source Node
|
|
450
|
-
|
|
450
|
+
|
|
451
451
|
const allDisclaimers = Object.values(firebaseData.disclaimers)
|
|
452
452
|
|
|
453
453
|
for (const disclaimer of allDisclaimers) {
|
|
@@ -483,12 +483,12 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
|
|
|
483
483
|
if (!brand || !brands[brand]) {
|
|
484
484
|
throw new Error(
|
|
485
485
|
`[gatsby-attainlabs-cms] Invalid or missing "brand" option.\n` +
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
486
|
+
`You must specify one of: ${Object.keys(brands).join(", ")}\n` +
|
|
487
|
+
`Example:\n` +
|
|
488
|
+
`{\n` +
|
|
489
|
+
` resolve: "gatsby-attainlabs-cms",\n` +
|
|
490
|
+
` options: { brand: "Cash Money" }\n` +
|
|
491
|
+
`}`
|
|
492
492
|
);
|
|
493
493
|
}
|
|
494
494
|
const firebaseData = await fetch(
|
|
@@ -538,6 +538,7 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
|
|
|
538
538
|
id,
|
|
539
539
|
} = page;
|
|
540
540
|
|
|
541
|
+
|
|
541
542
|
// Create slice for each block
|
|
542
543
|
await Promise.all(
|
|
543
544
|
content.map(async (b) => {
|
|
@@ -556,6 +557,7 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
|
|
|
556
557
|
},
|
|
557
558
|
});
|
|
558
559
|
|
|
560
|
+
console.log(sliceId)
|
|
559
561
|
b["sliceId"] = sliceId;
|
|
560
562
|
return b;
|
|
561
563
|
})
|
|
@@ -565,8 +567,10 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
|
|
|
565
567
|
const pageSource = await generatePage(content, layout, parentPath);
|
|
566
568
|
const folderPath = parentPath ? path.join(parentPath, pageUrl) : pageUrl;
|
|
567
569
|
const outPath = path.join(siteRoot, "src/cms/pages", `${folderPath}.tsx`);
|
|
570
|
+
const gatsbyPagePath = path.join(siteRoot, "src/pages", `${folderPath}.tsx`);
|
|
568
571
|
|
|
569
572
|
await fse.outputFile(outPath, pageSource);
|
|
573
|
+
await fse.remove(gatsbyPagePath)
|
|
570
574
|
|
|
571
575
|
await createPage({
|
|
572
576
|
path: folderPath.endsWith("index")
|
package/package.json
CHANGED
package/test-trust.js
ADDED
|
File without changes
|