gatsby-attainlabs-cms 1.0.46 → 1.0.47
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 +14 -5
- package/gatsby-node.js +78 -41
- package/package.json +1 -1
- package/src/sliceWrapper.tsx +12 -4
package/dist/sliceWrapper.js
CHANGED
|
@@ -12,7 +12,12 @@ export default function SliceWrapper({ sliceContext, data, }) {
|
|
|
12
12
|
console.warn(`Component "${pathFormatted}" not found in CMS_COMPONENTS`);
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
|
-
return (_jsx(Component, { ...props, trustPilotData: data.allTrustPilotReviews.edges[0].node,
|
|
15
|
+
return (_jsx(Component, { ...props, trustPilotData: data.allTrustPilotReviews.edges[0].node,
|
|
16
|
+
/* CHECK_DISCLAIMERS_START */
|
|
17
|
+
disclaimers: data.allDisclaimers,
|
|
18
|
+
/* CHECK_DISCLAIMERS_END */
|
|
19
|
+
/* CHECK_BLOGS_START */
|
|
20
|
+
blogs: {
|
|
16
21
|
sliderBlogs: {
|
|
17
22
|
...data.sliderBlogs,
|
|
18
23
|
},
|
|
@@ -54,15 +59,18 @@ export const TrustPilotQuery = graphql `
|
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
}
|
|
62
|
+
# CHECK_DISCLAIMERS_START
|
|
57
63
|
allDisclaimers: allAttainLabsCmsDisclaimers {
|
|
58
|
-
|
|
64
|
+
edges {
|
|
59
65
|
node {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
content
|
|
67
|
+
published
|
|
68
|
+
order
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
}
|
|
72
|
+
# CHECK_DISCLAIMERS_END
|
|
73
|
+
# CHECK_BLOGS_START
|
|
66
74
|
allBlogs: allAttainLabsCmsBlogs {
|
|
67
75
|
edges {
|
|
68
76
|
node {
|
|
@@ -126,5 +134,6 @@ export const TrustPilotQuery = graphql `
|
|
|
126
134
|
}
|
|
127
135
|
}
|
|
128
136
|
}
|
|
137
|
+
# CHECK_BLOGS_END
|
|
129
138
|
}
|
|
130
139
|
`;
|
package/gatsby-node.js
CHANGED
|
@@ -101,6 +101,7 @@ exports.onPreInit = async (_, pluginOptions) => {
|
|
|
101
101
|
azureBranch,
|
|
102
102
|
personalAccessToken: patOption,
|
|
103
103
|
environment,
|
|
104
|
+
fetch: fetchConfig,
|
|
104
105
|
} = pluginOptions;
|
|
105
106
|
|
|
106
107
|
// Try env first, then plugin option fallback
|
|
@@ -183,8 +184,38 @@ exports.onPreInit = async (_, pluginOptions) => {
|
|
|
183
184
|
}
|
|
184
185
|
const fileName = path.basename(localPath);
|
|
185
186
|
const destFile = path.join(targetPath, fileName);
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
|
|
188
|
+
if (fileName === "sliceWrapper.tsx") {
|
|
189
|
+
let content = fs.readFileSync(localPath, "utf8");
|
|
190
|
+
|
|
191
|
+
if (!fetchConfig || !fetchConfig.includes("blogs")) {
|
|
192
|
+
content = content.replace(
|
|
193
|
+
/# CHECK_BLOGS_START[\s\S]*?# CHECK_BLOGS_END/g,
|
|
194
|
+
""
|
|
195
|
+
);
|
|
196
|
+
content = content.replace(
|
|
197
|
+
/\/\* CHECK_BLOGS_START \*\/[\s\S]*?\/\* CHECK_BLOGS_END \*\//g,
|
|
198
|
+
""
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!fetchConfig || !fetchConfig.includes("disclaimers")) {
|
|
203
|
+
content = content.replace(
|
|
204
|
+
/# CHECK_DISCLAIMERS_START[\s\S]*?# CHECK_DISCLAIMERS_END/g,
|
|
205
|
+
""
|
|
206
|
+
);
|
|
207
|
+
content = content.replace(
|
|
208
|
+
/\/\* CHECK_DISCLAIMERS_START \*\/[\s\S]*?\/\* CHECK_DISCLAIMERS_END \*\//g,
|
|
209
|
+
""
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
fs.writeFileSync(destFile, content);
|
|
214
|
+
console.log(`✅ Copied and transformed ${destFile}`);
|
|
215
|
+
} else {
|
|
216
|
+
fs.copyFileSync(localPath, destFile);
|
|
217
|
+
console.log(`✅ Copied ${destFile}`);
|
|
218
|
+
}
|
|
188
219
|
});
|
|
189
220
|
|
|
190
221
|
// Loop through targets
|
|
@@ -321,7 +352,12 @@ exports.sourceNodes = async (
|
|
|
321
352
|
pluginOptions
|
|
322
353
|
) => {
|
|
323
354
|
const { createNode } = actions;
|
|
324
|
-
const {
|
|
355
|
+
const {
|
|
356
|
+
trustpilotApiKey,
|
|
357
|
+
brand,
|
|
358
|
+
environment,
|
|
359
|
+
fetch: fetchConfig,
|
|
360
|
+
} = pluginOptions;
|
|
325
361
|
const apiKey = process.env.TRUSTPILOT_API_KEY || trustpilotApiKey;
|
|
326
362
|
|
|
327
363
|
if (environment === "dev") {
|
|
@@ -410,7 +446,6 @@ exports.sourceNodes = async (
|
|
|
410
446
|
}
|
|
411
447
|
|
|
412
448
|
// Blogs node creation
|
|
413
|
-
|
|
414
449
|
const fetchData = async () => {
|
|
415
450
|
try {
|
|
416
451
|
const response = await fetch(
|
|
@@ -427,44 +462,46 @@ exports.sourceNodes = async (
|
|
|
427
462
|
}
|
|
428
463
|
};
|
|
429
464
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
// Disclaimers Source Node
|
|
451
|
-
|
|
452
|
-
const allDisclaimers = Object.values(firebaseData.disclaimers);
|
|
465
|
+
if (fetchConfig) {
|
|
466
|
+
const firebaseData = await fetchData();
|
|
467
|
+
if (fetchConfig.includes("blogs")) {
|
|
468
|
+
const allBlogs = getAllBlogs(firebaseData.pages);
|
|
469
|
+
for (const blog of allBlogs) {
|
|
470
|
+
const id = createNodeId(`attain-cms-blog-${blog.id}`);
|
|
471
|
+
const node = {
|
|
472
|
+
...blog,
|
|
473
|
+
id,
|
|
474
|
+
_id: blog.id,
|
|
475
|
+
parent: null,
|
|
476
|
+
children: [],
|
|
477
|
+
internal: {
|
|
478
|
+
type: "AttainLabsCmsBlogs",
|
|
479
|
+
contentDigest: createContentDigest(blog),
|
|
480
|
+
},
|
|
481
|
+
};
|
|
482
|
+
createNode(node);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
453
485
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
486
|
+
// Disclaimers Source Node
|
|
487
|
+
if (fetchConfig.includes("disclaimers")) {
|
|
488
|
+
const allDisclaimers = Object.values(firebaseData.disclaimers);
|
|
489
|
+
for (const disclaimer of allDisclaimers) {
|
|
490
|
+
const id = createNodeId(`attain-cms-disclaimer-${disclaimer.id}`);
|
|
491
|
+
const node = {
|
|
492
|
+
...disclaimer,
|
|
493
|
+
id,
|
|
494
|
+
_id: disclaimer.id,
|
|
495
|
+
parent: null,
|
|
496
|
+
children: [],
|
|
497
|
+
internal: {
|
|
498
|
+
type: "AttainLabsCmsDisclaimers",
|
|
499
|
+
contentDigest: createContentDigest(disclaimer),
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
createNode(node);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
468
505
|
}
|
|
469
506
|
};
|
|
470
507
|
|
package/package.json
CHANGED
package/src/sliceWrapper.tsx
CHANGED
|
@@ -31,7 +31,10 @@ export default function SliceWrapper({
|
|
|
31
31
|
<Component
|
|
32
32
|
{...props}
|
|
33
33
|
trustPilotData={data.allTrustPilotReviews.edges[0].node}
|
|
34
|
+
/* CHECK_DISCLAIMERS_START */
|
|
34
35
|
disclaimers={data.allDisclaimers}
|
|
36
|
+
/* CHECK_DISCLAIMERS_END */
|
|
37
|
+
/* CHECK_BLOGS_START */
|
|
35
38
|
blogs={{
|
|
36
39
|
sliderBlogs: {
|
|
37
40
|
...data.sliderBlogs,
|
|
@@ -40,6 +43,7 @@ export default function SliceWrapper({
|
|
|
40
43
|
...data.allBlogs,
|
|
41
44
|
},
|
|
42
45
|
}}
|
|
46
|
+
/* CHECK_BLOGS_END */
|
|
43
47
|
/>
|
|
44
48
|
);
|
|
45
49
|
}
|
|
@@ -77,15 +81,18 @@ export const TrustPilotQuery = graphql`
|
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
}
|
|
84
|
+
# CHECK_DISCLAIMERS_START
|
|
80
85
|
allDisclaimers: allAttainLabsCmsDisclaimers {
|
|
81
|
-
|
|
86
|
+
edges {
|
|
82
87
|
node {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
content
|
|
89
|
+
published
|
|
90
|
+
order
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
}
|
|
94
|
+
# CHECK_DISCLAIMERS_END
|
|
95
|
+
# CHECK_BLOGS_START
|
|
89
96
|
allBlogs: allAttainLabsCmsBlogs {
|
|
90
97
|
edges {
|
|
91
98
|
node {
|
|
@@ -149,5 +156,6 @@ export const TrustPilotQuery = graphql`
|
|
|
149
156
|
}
|
|
150
157
|
}
|
|
151
158
|
}
|
|
159
|
+
# CHECK_BLOGS_END
|
|
152
160
|
}
|
|
153
161
|
`;
|