@nitrogenbuilder/connector-payload 0.1.7 → 0.1.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.
@@ -14,7 +14,10 @@ export declare function buildPageResponse(doc: NitrogenPageDoc | NitrogenTemplat
14
14
  dynamic_data: JsonObject;
15
15
  settings: JsonObject;
16
16
  nitrogen_settings: {
17
- variables?: Array<{
17
+ variables?: Record<string, {
18
+ type?: string;
19
+ value?: string | boolean;
20
+ }> | Array<{
18
21
  name: string;
19
22
  value?: string;
20
23
  }>;
@@ -31,7 +34,10 @@ export declare function buildListItemResponse(doc: NitrogenPageDoc | NitrogenTem
31
34
  content: string;
32
35
  settings: JsonObject;
33
36
  nitrogen_settings: {
34
- variables?: Array<{
37
+ variables?: Record<string, {
38
+ type?: string;
39
+ value?: string | boolean;
40
+ }> | Array<{
35
41
  name: string;
36
42
  value?: string;
37
43
  }>;
@@ -19,9 +19,17 @@ export function buildDynamicData(doc, globalSettings) {
19
19
  : '',
20
20
  },
21
21
  };
22
- if (globalSettings?.nitrogenConfig?.variables) {
22
+ const rawVars = globalSettings?.nitrogenConfig?.variables;
23
+ if (rawVars && typeof rawVars === 'object' && !Array.isArray(rawVars)) {
23
24
  const vars = {};
24
- for (const item of globalSettings.nitrogenConfig.variables) {
25
+ for (const [name, variable] of Object.entries(rawVars)) {
26
+ vars[name] = String(variable?.value ?? '');
27
+ }
28
+ dynamicData['Global Variables'] = vars;
29
+ }
30
+ else if (Array.isArray(rawVars)) {
31
+ const vars = {};
32
+ for (const item of rawVars) {
25
33
  if (item.name) {
26
34
  vars[item.name] = item.value ?? '';
27
35
  }
package/dist/types.d.ts CHANGED
@@ -38,7 +38,10 @@ export interface NitrogenSettingsGlobal {
38
38
  nitrogenConfig?: NitrogenConfig;
39
39
  }
40
40
  export interface NitrogenConfig {
41
- variables?: Array<{
41
+ variables?: Record<string, {
42
+ type?: string;
43
+ value?: string | boolean;
44
+ }> | Array<{
42
45
  name: string;
43
46
  value?: string;
44
47
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitrogenbuilder/connector-payload",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Nitrogen page builder connector plugin for Payload CMS 3.x",
5
5
  "author": "Leonardo Dentzien <leo@torchmedia.ca>",
6
6
  "type": "module",
@@ -46,4 +46,4 @@
46
46
  "@nitrogenbuilder/client-core": "link:../monogen/packages/client-core",
47
47
  "@nitrogenbuilder/types": "link:../monogen/packages/types"
48
48
  }
49
- }
49
+ }