gatsby-attainlabs-cms 1.0.5 → 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/README.md CHANGED
@@ -53,7 +53,7 @@ require("dotenv").config({
53
53
  module.exports = {
54
54
  plugins: [
55
55
  {
56
- resolve: "gatsby-plugin-your-plugin",
56
+ resolve: "gatsby-attainlabs-cms",
57
57
  options: {
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
@@ -67,9 +67,10 @@ module.exports = {
67
67
 
68
68
  ## Behavior
69
69
 
70
- - Downloads brand-specific `index.tsx` components into:
70
+ - Downloads brand-specific components into:
71
71
  - `src/cms/components/brand/`
72
72
  - `src/cms/components/global/`
73
+ - `src/cms/gatsby-plugin-theme-ui/`
73
74
 
74
75
  - Requires an Azure DevOps Personal Access Token (PAT) to authenticate requests.
75
76
 
@@ -90,10 +91,10 @@ module.exports = {
90
91
  If you see:
91
92
 
92
93
  ```
93
- ⚠️ [gatsby-plugin-your-plugin] No PERSONAL_ACCESS_TOKEN found...
94
+ ⚠️ [gatsby-attainlabs-cms] No PERSONAL_ACCESS_TOKEN found...
94
95
  ```
95
96
 
96
- ➡️ Double-check that `.env.development` or `.env.production` exists and is loaded in `gatsby-config.js`.
97
+ ➡️ Double-check that `.env` exists and is loaded in `gatsby-config.js`.
97
98
 
98
99
  ---
99
100
 
@@ -102,7 +103,7 @@ If you see:
102
103
  If you see:
103
104
 
104
105
  ```
105
- [gatsby-plugin-your-plugin] Invalid or missing "brand" option.
106
+ [gatsby-attainlabs-cms] Invalid or missing "brand" option.
106
107
  You must specify one of: LendDirect, Cash Money, Heights Finance
107
108
  ```
108
109
 
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/brand"),
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/global"),
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.5",
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 `index.tsx` components from the **Attain Labs CMS** hosted in Azure Repos into your Gatsby project at build time.",
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
  },