gatsby-attainlabs-cms 1.0.7 → 1.0.9
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/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/gatsby-node.js +0 -32
- package/package.json +9 -3
- package/src/index.ts +18 -0
- package/tsconfig.json +15 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { SliceComponentProps } from "gatsby";
|
|
3
|
+
interface SliceWrapperProps extends SliceComponentProps {
|
|
4
|
+
sliceContext: {
|
|
5
|
+
componentPath: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
declare function SliceWrapper({ sliceContext }: SliceWrapperProps): React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
9
|
+
export { SliceWrapper };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
function SliceWrapper({ sliceContext }) {
|
|
3
|
+
const { componentPath, ...props } = sliceContext;
|
|
4
|
+
// Dynamically import your component
|
|
5
|
+
const Component = require(componentPath).default;
|
|
6
|
+
return React.createElement(Component, props);
|
|
7
|
+
}
|
|
8
|
+
export { SliceWrapper };
|
package/gatsby-node.js
CHANGED
|
@@ -173,35 +173,3 @@ 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,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-attainlabs-cms",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
5
7
|
"type": "module",
|
|
6
8
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"build": "tsc"
|
|
8
11
|
},
|
|
9
12
|
"author": "Anthony Barrera",
|
|
10
13
|
"license": "ISC",
|
|
@@ -15,5 +18,8 @@
|
|
|
15
18
|
"dependencies": {
|
|
16
19
|
"dotenv": "^17.2.1",
|
|
17
20
|
"react-slick": "^0.31.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.9.2"
|
|
18
24
|
}
|
|
19
25
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { SliceComponentProps } from "gatsby";
|
|
3
|
+
|
|
4
|
+
interface SliceWrapperProps extends SliceComponentProps {
|
|
5
|
+
sliceContext: {
|
|
6
|
+
componentPath: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function SliceWrapper({ sliceContext }: SliceWrapperProps) {
|
|
11
|
+
const { componentPath, ...props } = sliceContext;
|
|
12
|
+
|
|
13
|
+
// Dynamically import your component
|
|
14
|
+
const Component = require(componentPath).default;
|
|
15
|
+
return React.createElement(Component, props);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { SliceWrapper };
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"],
|
|
14
|
+
"exclude": ["dist"]
|
|
15
|
+
}
|