gatsby-attainlabs-cms 1.0.6 → 1.0.7
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 +34 -2
- package/package.json +2 -2
package/gatsby-node.js
CHANGED
|
@@ -48,12 +48,12 @@ export const onPreInit = async (_, pluginOptions) => {
|
|
|
48
48
|
const targets = [
|
|
49
49
|
{
|
|
50
50
|
repoPath: `/apps/cms/src/cms/components/editor/visual-block-editor/components/brands/${brands[brand]}`,
|
|
51
|
-
localBasePath: path.resolve("./src/cms/components/
|
|
51
|
+
localBasePath: path.resolve("./src/cms/components/"),
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
repoPath:
|
|
55
55
|
"/apps/cms/src/cms/components/editor/visual-block-editor/components/global/blocks",
|
|
56
|
-
localBasePath: path.resolve("./src/cms/components/
|
|
56
|
+
localBasePath: path.resolve("./src/cms/components/"),
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
repoPath: `/apps/cms/src/gatsby-plugin-theme-ui/${brands[brand]}`,
|
|
@@ -173,3 +173,35 @@ export const onPreInit = async (_, pluginOptions) => {
|
|
|
173
173
|
doRequest(fileUrl);
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
|
+
|
|
177
|
+
export const sourceNodes = async (
|
|
178
|
+
{ actions, createNodeId, createContentDigest },
|
|
179
|
+
pluginOptions
|
|
180
|
+
) => {
|
|
181
|
+
const { createNode } = actions;
|
|
182
|
+
const { brand } = pluginOptions;
|
|
183
|
+
|
|
184
|
+
const data = await fetch(
|
|
185
|
+
`https://attain-finance-cms-default-rtdb.firebaseio.com/cms/brands/${brand}.json`
|
|
186
|
+
);
|
|
187
|
+
if (!data.ok) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
`Failed to fetch brand data: ${data.status} ${data.statusText}`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
const brandData = await data.json();
|
|
193
|
+
|
|
194
|
+
// Example: create a simple node with brand info
|
|
195
|
+
const brandNode = {
|
|
196
|
+
id: createNodeId(`brand-${brand}`),
|
|
197
|
+
parent: null,
|
|
198
|
+
children: [],
|
|
199
|
+
internal: {
|
|
200
|
+
type: "BrandInfo",
|
|
201
|
+
contentDigest: createContentDigest(brand),
|
|
202
|
+
},
|
|
203
|
+
name: brand,
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
createNode(brandNode);
|
|
207
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-attainlabs-cms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"main": "gatsby-node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"author": "Anthony Barrera",
|
|
10
10
|
"license": "ISC",
|
|
11
|
-
"description": "A Gatsby plugin that downloads and syncs
|
|
11
|
+
"description": "A Gatsby plugin that downloads and syncs components from the **Attain Labs CMS** hosted in Azure Repos into your Gatsby project at build time.",
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"gatsby": "^5.0.0 || ^4.0.0"
|
|
14
14
|
},
|