@driveflux/cms 1.4.8 → 1.4.10
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/config.js +6 -12
- package/dist/hygraph/drivers/graphcms.js +611 -842
- package/dist/hygraph/hygraph.js +1 -1
- package/dist/hygraph/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,905 +1,674 @@
|
|
|
1
|
-
function _array_like_to_array(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _array_without_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
-
}
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
-
try {
|
|
11
|
-
var info = gen[key](arg);
|
|
12
|
-
var value = info.value;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
reject(error);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (info.done) {
|
|
18
|
-
resolve(value);
|
|
19
|
-
} else {
|
|
20
|
-
Promise.resolve(value).then(_next, _throw);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function _async_to_generator(fn) {
|
|
24
|
-
return function() {
|
|
25
|
-
var self = this, args = arguments;
|
|
26
|
-
return new Promise(function(resolve, reject) {
|
|
27
|
-
var gen = fn.apply(self, args);
|
|
28
|
-
function _next(value) {
|
|
29
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
-
}
|
|
31
|
-
function _throw(err) {
|
|
32
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
-
}
|
|
34
|
-
_next(undefined);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
39
|
-
if (privateCollection.has(obj)) {
|
|
40
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
44
|
-
if (descriptor.get) {
|
|
45
|
-
return descriptor.get.call(receiver);
|
|
46
|
-
}
|
|
47
|
-
return descriptor.value;
|
|
48
|
-
}
|
|
49
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
50
|
-
if (descriptor.set) {
|
|
51
|
-
descriptor.set.call(receiver, value);
|
|
52
|
-
} else {
|
|
53
|
-
if (!descriptor.writable) {
|
|
54
|
-
throw new TypeError("attempted to set read only private field");
|
|
55
|
-
}
|
|
56
|
-
descriptor.value = value;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function _class_call_check(instance, Constructor) {
|
|
60
|
-
if (!(instance instanceof Constructor)) {
|
|
61
|
-
throw new TypeError("Cannot call a class as a function");
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
65
|
-
if (!privateMap.has(receiver)) {
|
|
66
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
67
|
-
}
|
|
68
|
-
return privateMap.get(receiver);
|
|
69
|
-
}
|
|
70
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
71
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
72
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
73
|
-
}
|
|
74
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
75
|
-
_check_private_redeclaration(obj, privateMap);
|
|
76
|
-
privateMap.set(obj, value);
|
|
77
|
-
}
|
|
78
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
79
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
80
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
function _defineProperties(target, props) {
|
|
84
|
-
for(var i = 0; i < props.length; i++){
|
|
85
|
-
var descriptor = props[i];
|
|
86
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
87
|
-
descriptor.configurable = true;
|
|
88
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
89
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
93
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
94
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
95
|
-
return Constructor;
|
|
96
|
-
}
|
|
97
|
-
function _define_property(obj, key, value) {
|
|
98
|
-
if (key in obj) {
|
|
99
|
-
Object.defineProperty(obj, key, {
|
|
100
|
-
value: value,
|
|
101
|
-
enumerable: true,
|
|
102
|
-
configurable: true,
|
|
103
|
-
writable: true
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
obj[key] = value;
|
|
107
|
-
}
|
|
108
|
-
return obj;
|
|
109
|
-
}
|
|
110
|
-
function _iterable_to_array(iter) {
|
|
111
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
112
|
-
}
|
|
113
|
-
function _non_iterable_spread() {
|
|
114
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
115
|
-
}
|
|
116
|
-
function _object_spread(target) {
|
|
117
|
-
for(var i = 1; i < arguments.length; i++){
|
|
118
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
119
|
-
var ownKeys = Object.keys(source);
|
|
120
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
121
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
122
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
ownKeys.forEach(function(key) {
|
|
126
|
-
_define_property(target, key, source[key]);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
return target;
|
|
130
|
-
}
|
|
131
|
-
function ownKeys(object, enumerableOnly) {
|
|
132
|
-
var keys = Object.keys(object);
|
|
133
|
-
if (Object.getOwnPropertySymbols) {
|
|
134
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
135
|
-
if (enumerableOnly) {
|
|
136
|
-
symbols = symbols.filter(function(sym) {
|
|
137
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
keys.push.apply(keys, symbols);
|
|
141
|
-
}
|
|
142
|
-
return keys;
|
|
143
|
-
}
|
|
144
|
-
function _object_spread_props(target, source) {
|
|
145
|
-
source = source != null ? source : {};
|
|
146
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
147
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
148
|
-
} else {
|
|
149
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
150
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
return target;
|
|
154
|
-
}
|
|
155
|
-
function _object_without_properties(source, excluded) {
|
|
156
|
-
if (source == null) return {};
|
|
157
|
-
var target = _object_without_properties_loose(source, excluded);
|
|
158
|
-
var key, i;
|
|
159
|
-
if (Object.getOwnPropertySymbols) {
|
|
160
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
161
|
-
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
162
|
-
key = sourceSymbolKeys[i];
|
|
163
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
164
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
165
|
-
target[key] = source[key];
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return target;
|
|
169
|
-
}
|
|
170
|
-
function _object_without_properties_loose(source, excluded) {
|
|
171
|
-
if (source == null) return {};
|
|
172
|
-
var target = {};
|
|
173
|
-
var sourceKeys = Object.keys(source);
|
|
174
|
-
var key, i;
|
|
175
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
176
|
-
key = sourceKeys[i];
|
|
177
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
178
|
-
target[key] = source[key];
|
|
179
|
-
}
|
|
180
|
-
return target;
|
|
181
|
-
}
|
|
182
|
-
function _to_consumable_array(arr) {
|
|
183
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
184
|
-
}
|
|
185
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
186
|
-
if (!o) return;
|
|
187
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
188
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
189
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
190
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
191
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
192
|
-
}
|
|
193
|
-
function _ts_generator(thisArg, body) {
|
|
194
|
-
var f, y, t, g, _ = {
|
|
195
|
-
label: 0,
|
|
196
|
-
sent: function() {
|
|
197
|
-
if (t[0] & 1) throw t[1];
|
|
198
|
-
return t[1];
|
|
199
|
-
},
|
|
200
|
-
trys: [],
|
|
201
|
-
ops: []
|
|
202
|
-
};
|
|
203
|
-
return g = {
|
|
204
|
-
next: verb(0),
|
|
205
|
-
"throw": verb(1),
|
|
206
|
-
"return": verb(2)
|
|
207
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
208
|
-
return this;
|
|
209
|
-
}), g;
|
|
210
|
-
function verb(n) {
|
|
211
|
-
return function(v) {
|
|
212
|
-
return step([
|
|
213
|
-
n,
|
|
214
|
-
v
|
|
215
|
-
]);
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
function step(op) {
|
|
219
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
220
|
-
while(_)try {
|
|
221
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
222
|
-
if (y = 0, t) op = [
|
|
223
|
-
op[0] & 2,
|
|
224
|
-
t.value
|
|
225
|
-
];
|
|
226
|
-
switch(op[0]){
|
|
227
|
-
case 0:
|
|
228
|
-
case 1:
|
|
229
|
-
t = op;
|
|
230
|
-
break;
|
|
231
|
-
case 4:
|
|
232
|
-
_.label++;
|
|
233
|
-
return {
|
|
234
|
-
value: op[1],
|
|
235
|
-
done: false
|
|
236
|
-
};
|
|
237
|
-
case 5:
|
|
238
|
-
_.label++;
|
|
239
|
-
y = op[1];
|
|
240
|
-
op = [
|
|
241
|
-
0
|
|
242
|
-
];
|
|
243
|
-
continue;
|
|
244
|
-
case 7:
|
|
245
|
-
op = _.ops.pop();
|
|
246
|
-
_.trys.pop();
|
|
247
|
-
continue;
|
|
248
|
-
default:
|
|
249
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
250
|
-
_ = 0;
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
254
|
-
_.label = op[1];
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
258
|
-
_.label = t[1];
|
|
259
|
-
t = op;
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
if (t && _.label < t[2]) {
|
|
263
|
-
_.label = t[2];
|
|
264
|
-
_.ops.push(op);
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
if (t[2]) _.ops.pop();
|
|
268
|
-
_.trys.pop();
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
op = body.call(thisArg, _);
|
|
272
|
-
} catch (e) {
|
|
273
|
-
op = [
|
|
274
|
-
6,
|
|
275
|
-
e
|
|
276
|
-
];
|
|
277
|
-
y = 0;
|
|
278
|
-
} finally{
|
|
279
|
-
f = t = 0;
|
|
280
|
-
}
|
|
281
|
-
if (op[0] & 5) throw op[1];
|
|
282
|
-
return {
|
|
283
|
-
value: op[0] ? op[1] : void 0,
|
|
284
|
-
done: true
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
1
|
import { cloneDeep } from '@driveflux/utils';
|
|
289
2
|
import pThrottle from 'p-throttle';
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
var _section_images, _section_vehicles, _section_reviews;
|
|
311
|
-
var data = {
|
|
312
|
-
name: name,
|
|
313
|
-
image: (_section_images = section.images) === null || _section_images === void 0 ? void 0 : _section_images[i],
|
|
314
|
-
vehicle: (_section_vehicles = section.vehicles) === null || _section_vehicles === void 0 ? void 0 : _section_vehicles[i],
|
|
315
|
-
review: (_section_reviews = section.reviews) === null || _section_reviews === void 0 ? void 0 : _section_reviews[i]
|
|
3
|
+
const headerProps = ({ header, forceHeaderAlign })=>({
|
|
4
|
+
header,
|
|
5
|
+
forceHeaderAlign
|
|
6
|
+
});
|
|
7
|
+
const buttonProps = ({ buttonLink, buttonText })=>({
|
|
8
|
+
buttonLink,
|
|
9
|
+
buttonText
|
|
10
|
+
});
|
|
11
|
+
const DEFAULT_SECTION_HANDLERS = {
|
|
12
|
+
Reviews: (section)=>{
|
|
13
|
+
return {
|
|
14
|
+
__typename: section.__typename,
|
|
15
|
+
...headerProps(section),
|
|
16
|
+
...buttonProps(section),
|
|
17
|
+
reviews: section.names.map((name, i)=>{
|
|
18
|
+
const data = {
|
|
19
|
+
name,
|
|
20
|
+
image: section.images?.[i],
|
|
21
|
+
vehicle: section.vehicles?.[i],
|
|
22
|
+
review: section.reviews?.[i]
|
|
316
23
|
};
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
var key = _step.value;
|
|
321
|
-
if (data[key] === undefined) {
|
|
322
|
-
delete data[key];
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
} catch (err) {
|
|
326
|
-
_didIteratorError = true;
|
|
327
|
-
_iteratorError = err;
|
|
328
|
-
} finally{
|
|
329
|
-
try {
|
|
330
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
331
|
-
_iterator.return();
|
|
332
|
-
}
|
|
333
|
-
} finally{
|
|
334
|
-
if (_didIteratorError) {
|
|
335
|
-
throw _iteratorError;
|
|
336
|
-
}
|
|
24
|
+
for (const key of Object.keys(data)){
|
|
25
|
+
if (data[key] === undefined) {
|
|
26
|
+
delete data[key];
|
|
337
27
|
}
|
|
338
28
|
}
|
|
339
29
|
return data;
|
|
340
30
|
})
|
|
341
|
-
}
|
|
31
|
+
};
|
|
342
32
|
},
|
|
343
|
-
VehicleShowcase:
|
|
344
|
-
return
|
|
345
|
-
__typename: section.__typename
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
topTitle
|
|
351
|
-
secondaryTitle:
|
|
352
|
-
photo:
|
|
353
|
-
content:
|
|
33
|
+
VehicleShowcase: (section)=>{
|
|
34
|
+
return {
|
|
35
|
+
__typename: section.__typename,
|
|
36
|
+
...headerProps(section),
|
|
37
|
+
...buttonProps(section),
|
|
38
|
+
vehicles: section.topTitles.map((topTitle, i)=>{
|
|
39
|
+
const data = {
|
|
40
|
+
topTitle,
|
|
41
|
+
secondaryTitle: section.secondaryTitles?.[i],
|
|
42
|
+
photo: section.photos?.[i],
|
|
43
|
+
content: section.contents?.[i]
|
|
354
44
|
};
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
var key = _step.value;
|
|
359
|
-
if (data[key] === undefined) {
|
|
360
|
-
delete data[key];
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
} catch (err) {
|
|
364
|
-
_didIteratorError = true;
|
|
365
|
-
_iteratorError = err;
|
|
366
|
-
} finally{
|
|
367
|
-
try {
|
|
368
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
369
|
-
_iterator.return();
|
|
370
|
-
}
|
|
371
|
-
} finally{
|
|
372
|
-
if (_didIteratorError) {
|
|
373
|
-
throw _iteratorError;
|
|
374
|
-
}
|
|
45
|
+
for (const key of Object.keys(data)){
|
|
46
|
+
if (data[key] === undefined) {
|
|
47
|
+
delete data[key];
|
|
375
48
|
}
|
|
376
49
|
}
|
|
377
50
|
return data;
|
|
378
51
|
})
|
|
379
|
-
}
|
|
52
|
+
};
|
|
380
53
|
},
|
|
381
|
-
MultiplePhotoCaption:
|
|
382
|
-
return
|
|
383
|
-
__typename: section.__typename
|
|
384
|
-
|
|
54
|
+
MultiplePhotoCaption: (section)=>{
|
|
55
|
+
return {
|
|
56
|
+
__typename: section.__typename,
|
|
57
|
+
...headerProps(section),
|
|
58
|
+
...buttonProps(section),
|
|
385
59
|
useIconSize: section.useIconSize,
|
|
386
|
-
photoCaptions: section.photos.map(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
title: (_section_titles = section.titles) === null || _section_titles === void 0 ? void 0 : _section_titles[i]
|
|
60
|
+
photoCaptions: section.photos.map((photo, i)=>{
|
|
61
|
+
const data = {
|
|
62
|
+
photo,
|
|
63
|
+
description: section.descriptions?.[i],
|
|
64
|
+
title: section.titles?.[i]
|
|
392
65
|
};
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
var key = _step.value;
|
|
397
|
-
if (data[key] === undefined) {
|
|
398
|
-
delete data[key];
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
} catch (err) {
|
|
402
|
-
_didIteratorError = true;
|
|
403
|
-
_iteratorError = err;
|
|
404
|
-
} finally{
|
|
405
|
-
try {
|
|
406
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
407
|
-
_iterator.return();
|
|
408
|
-
}
|
|
409
|
-
} finally{
|
|
410
|
-
if (_didIteratorError) {
|
|
411
|
-
throw _iteratorError;
|
|
412
|
-
}
|
|
66
|
+
for (const key of Object.keys(data)){
|
|
67
|
+
if (data[key] === undefined) {
|
|
68
|
+
delete data[key];
|
|
413
69
|
}
|
|
414
70
|
}
|
|
415
71
|
return data;
|
|
416
72
|
})
|
|
417
|
-
}
|
|
73
|
+
};
|
|
418
74
|
},
|
|
419
|
-
PhotoCarousel:
|
|
420
|
-
return
|
|
421
|
-
__typename: section.__typename
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
photo
|
|
427
|
-
title:
|
|
428
|
-
href:
|
|
75
|
+
PhotoCarousel: (section)=>{
|
|
76
|
+
return {
|
|
77
|
+
__typename: section.__typename,
|
|
78
|
+
...headerProps(section),
|
|
79
|
+
...buttonProps(section),
|
|
80
|
+
photos: section.photos.map((photo, i)=>{
|
|
81
|
+
const data = {
|
|
82
|
+
photo,
|
|
83
|
+
title: section.titles?.[i],
|
|
84
|
+
href: section.hrefs?.[i]
|
|
429
85
|
};
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
var key = _step.value;
|
|
434
|
-
if (data[key] === undefined) {
|
|
435
|
-
delete data[key];
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
} catch (err) {
|
|
439
|
-
_didIteratorError = true;
|
|
440
|
-
_iteratorError = err;
|
|
441
|
-
} finally{
|
|
442
|
-
try {
|
|
443
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
444
|
-
_iterator.return();
|
|
445
|
-
}
|
|
446
|
-
} finally{
|
|
447
|
-
if (_didIteratorError) {
|
|
448
|
-
throw _iteratorError;
|
|
449
|
-
}
|
|
86
|
+
for (const key of Object.keys(data)){
|
|
87
|
+
if (data[key] === undefined) {
|
|
88
|
+
delete data[key];
|
|
450
89
|
}
|
|
451
90
|
}
|
|
452
91
|
return data;
|
|
453
92
|
})
|
|
454
|
-
}
|
|
93
|
+
};
|
|
455
94
|
},
|
|
456
|
-
BigTextColumns:
|
|
457
|
-
return
|
|
458
|
-
__typename: section.__typename
|
|
459
|
-
|
|
95
|
+
BigTextColumns: (section)=>{
|
|
96
|
+
return {
|
|
97
|
+
__typename: section.__typename,
|
|
98
|
+
...headerProps(section),
|
|
99
|
+
...buttonProps(section),
|
|
460
100
|
content: section.content,
|
|
461
|
-
columns: section.bigTitles.map(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
description: (_section_descriptions = section.descriptions) === null || _section_descriptions === void 0 ? void 0 : _section_descriptions[i]
|
|
101
|
+
columns: section.bigTitles.map((bigTitle, i)=>{
|
|
102
|
+
const data = {
|
|
103
|
+
bigTitle,
|
|
104
|
+
smallTitle: section.smallTitles?.[i],
|
|
105
|
+
description: section.descriptions?.[i]
|
|
467
106
|
};
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
var key = _step.value;
|
|
472
|
-
if (data[key] === undefined) {
|
|
473
|
-
delete data[key];
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
} catch (err) {
|
|
477
|
-
_didIteratorError = true;
|
|
478
|
-
_iteratorError = err;
|
|
479
|
-
} finally{
|
|
480
|
-
try {
|
|
481
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
482
|
-
_iterator.return();
|
|
483
|
-
}
|
|
484
|
-
} finally{
|
|
485
|
-
if (_didIteratorError) {
|
|
486
|
-
throw _iteratorError;
|
|
487
|
-
}
|
|
107
|
+
for (const key of Object.keys(data)){
|
|
108
|
+
if (data[key] === undefined) {
|
|
109
|
+
delete data[key];
|
|
488
110
|
}
|
|
489
111
|
}
|
|
490
112
|
return data;
|
|
491
113
|
})
|
|
492
|
-
}
|
|
114
|
+
};
|
|
493
115
|
}
|
|
494
116
|
};
|
|
495
|
-
|
|
117
|
+
const throttle = pThrottle({
|
|
496
118
|
limit: 5,
|
|
497
119
|
interval: 1000
|
|
498
120
|
});
|
|
499
|
-
export
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
});
|
|
507
|
-
});
|
|
508
|
-
return function(req, init) {
|
|
509
|
-
return _ref.apply(this, arguments);
|
|
510
|
-
};
|
|
511
|
-
}());
|
|
512
|
-
var _config = /*#__PURE__*/ new WeakMap(), _locale = /*#__PURE__*/ new WeakMap(), _sectionHandlers = /*#__PURE__*/ new WeakMap();
|
|
513
|
-
export var GraphCMS = /*#__PURE__*/ function() {
|
|
514
|
-
"use strict";
|
|
515
|
-
function GraphCMS(config) {
|
|
516
|
-
var preview = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, locale = arguments.length > 2 ? arguments[2] : void 0;
|
|
517
|
-
_class_call_check(this, GraphCMS);
|
|
518
|
-
_define_property(this, "preview", void 0);
|
|
519
|
-
_class_private_field_init(this, _config, {
|
|
520
|
-
writable: true,
|
|
521
|
-
value: void 0
|
|
522
|
-
});
|
|
523
|
-
_class_private_field_init(this, _locale, {
|
|
524
|
-
writable: true,
|
|
525
|
-
value: void 0
|
|
526
|
-
});
|
|
527
|
-
_class_private_field_init(this, _sectionHandlers, {
|
|
528
|
-
writable: true,
|
|
529
|
-
value: void 0
|
|
530
|
-
});
|
|
121
|
+
export const throttledFetch = throttle(async (req, init)=>fetch(req, init));
|
|
122
|
+
export class GraphCMS {
|
|
123
|
+
preview;
|
|
124
|
+
#config;
|
|
125
|
+
#locale;
|
|
126
|
+
#sectionHandlers;
|
|
127
|
+
constructor(config, preview = false, locale){
|
|
531
128
|
this.preview = preview;
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
129
|
+
this.#config = config;
|
|
130
|
+
this.#locale = locale;
|
|
131
|
+
this.#sectionHandlers = DEFAULT_SECTION_HANDLERS;
|
|
535
132
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
})
|
|
565
|
-
})
|
|
566
|
-
})
|
|
567
|
-
];
|
|
568
|
-
case 1:
|
|
569
|
-
res = _state.sent();
|
|
570
|
-
return [
|
|
571
|
-
4,
|
|
572
|
-
res.json()
|
|
573
|
-
];
|
|
574
|
-
case 2:
|
|
575
|
-
json = _state.sent();
|
|
576
|
-
if (json.errors) {
|
|
577
|
-
console.error('GraphCMS Error:', JSON.stringify(json.errors, undefined, 2));
|
|
578
|
-
error = new Error('Failed to fetch API');
|
|
579
|
-
if (res.status === 429) {
|
|
580
|
-
// @ts-expect-error
|
|
581
|
-
error.limitsReached = true;
|
|
582
|
-
}
|
|
583
|
-
throw error;
|
|
584
|
-
}
|
|
585
|
-
return [
|
|
586
|
-
2,
|
|
587
|
-
json.data
|
|
588
|
-
];
|
|
589
|
-
}
|
|
590
|
-
});
|
|
591
|
-
})();
|
|
133
|
+
async fetchAPI(query, variables) {
|
|
134
|
+
// TODO
|
|
135
|
+
//@ts-expect-error - this is a browser import, we will fix it later!
|
|
136
|
+
const headers = {
|
|
137
|
+
'Content-Type': 'application/json',
|
|
138
|
+
Authorization: `Bearer ${this.preview ? this.#config.devAuthToken : this.#config.prodAuthToken}`
|
|
139
|
+
};
|
|
140
|
+
if (this.#locale) {
|
|
141
|
+
headers['gcms-locales'] = `${this.#locale},en`;
|
|
142
|
+
}
|
|
143
|
+
const res = await throttledFetch(this.#config.projectApi, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
headers,
|
|
146
|
+
body: JSON.stringify({
|
|
147
|
+
query,
|
|
148
|
+
variables: {
|
|
149
|
+
...variables,
|
|
150
|
+
stage: this.stage()
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
const json = await res.json();
|
|
155
|
+
if (json.errors) {
|
|
156
|
+
console.error('GraphCMS Error:', JSON.stringify(json.errors, undefined, 2));
|
|
157
|
+
const error = new Error('Failed to fetch API');
|
|
158
|
+
if (res.status === 429) {
|
|
159
|
+
// @ts-expect-error
|
|
160
|
+
error.limitsReached = true;
|
|
592
161
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
return json.data;
|
|
165
|
+
}
|
|
166
|
+
stage() {
|
|
167
|
+
return this.preview ? 'DRAFT' : 'PUBLISHED';
|
|
168
|
+
}
|
|
169
|
+
async getPostById(id) {
|
|
170
|
+
const data = await this.fetchAPI(`
|
|
171
|
+
query PostById($id: ID!, $stage: Stage!) {
|
|
172
|
+
post(where: {id: $id}, stage: $stage) {
|
|
173
|
+
id
|
|
174
|
+
title
|
|
175
|
+
slug
|
|
176
|
+
date
|
|
177
|
+
excerpt
|
|
178
|
+
content {
|
|
179
|
+
json
|
|
180
|
+
references {
|
|
181
|
+
__typename
|
|
182
|
+
... on Asset {
|
|
183
|
+
url
|
|
184
|
+
handle
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
coverImage {
|
|
190
|
+
url(transformation: {
|
|
191
|
+
image: {
|
|
192
|
+
resize: {
|
|
193
|
+
fit:crop,
|
|
194
|
+
width:585,
|
|
195
|
+
height:350
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
author {
|
|
202
|
+
name
|
|
203
|
+
picture {
|
|
204
|
+
url(transformation: {
|
|
205
|
+
image: {
|
|
206
|
+
resize: {
|
|
207
|
+
fit:crop,
|
|
208
|
+
width:60,
|
|
209
|
+
height:60
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
})
|
|
598
213
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
featured
|
|
217
|
+
category
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
`, {
|
|
221
|
+
id
|
|
222
|
+
});
|
|
223
|
+
return data.post;
|
|
224
|
+
}
|
|
225
|
+
async getPost(slug) {
|
|
226
|
+
const data1 = await this.fetchAPI(`
|
|
227
|
+
query PostBySlug($slug: String!, $stage: Stage!) {
|
|
228
|
+
post(where: {slug: $slug}, stage: $stage) {
|
|
229
|
+
id
|
|
230
|
+
title
|
|
231
|
+
slug
|
|
232
|
+
date
|
|
233
|
+
excerpt
|
|
234
|
+
content {
|
|
235
|
+
json
|
|
236
|
+
references {
|
|
237
|
+
__typename
|
|
238
|
+
... on Asset {
|
|
239
|
+
url
|
|
240
|
+
handle
|
|
241
|
+
}
|
|
624
242
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
4,
|
|
652
|
-
_this.fetchAPI("\n query PostsMeta($postId: String!, $stage: Stage!) {\n next: posts(first: 1, after: $postId, stage: $stage) {\n title\n slug\n }\n previous: posts(first: 1, before: $postId, stage: $stage) {\n title\n slug\n }\n\n latest: posts(first: 3) {\n title\n slug\n excerpt\n coverImage {\n url(transformation: {\n image: {\n resize: {\n fit:crop,\n width:585,\n height:350\n }\n }\n }) \n }\n category\n }\n }\n ", {
|
|
653
|
-
postId: post.id
|
|
654
|
-
})
|
|
655
|
-
];
|
|
656
|
-
case 2:
|
|
657
|
-
data2 = _state.sent();
|
|
658
|
-
return [
|
|
659
|
-
2,
|
|
660
|
-
_object_spread_props(_object_spread({}, data1), {
|
|
661
|
-
next: (_data2_next = data2.next) === null || _data2_next === void 0 ? void 0 : _data2_next[0],
|
|
662
|
-
previous: (_data2_previous = data2.previous) === null || _data2_previous === void 0 ? void 0 : _data2_previous[0],
|
|
663
|
-
latest: data2.latest
|
|
664
|
-
})
|
|
665
|
-
];
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
})();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
coverImage {
|
|
246
|
+
url(transformation: {
|
|
247
|
+
image: {
|
|
248
|
+
resize: {
|
|
249
|
+
fit:crop,
|
|
250
|
+
width:585,
|
|
251
|
+
height:350
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
author {
|
|
258
|
+
name
|
|
259
|
+
picture {
|
|
260
|
+
url(transformation: {
|
|
261
|
+
image: {
|
|
262
|
+
resize: {
|
|
263
|
+
fit:crop,
|
|
264
|
+
width:60,
|
|
265
|
+
height:60
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
})
|
|
669
269
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
featured
|
|
273
|
+
category
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
`, {
|
|
277
|
+
slug
|
|
278
|
+
});
|
|
279
|
+
const post = data1.post;
|
|
280
|
+
if (!post) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
const data2 = await this.fetchAPI(`
|
|
284
|
+
query PostsMeta($postId: String!, $stage: Stage!) {
|
|
285
|
+
next: posts(first: 1, after: $postId, stage: $stage) {
|
|
286
|
+
title
|
|
287
|
+
slug
|
|
288
|
+
}
|
|
289
|
+
previous: posts(first: 1, before: $postId, stage: $stage) {
|
|
290
|
+
title
|
|
291
|
+
slug
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
latest: posts(first: 3) {
|
|
295
|
+
title
|
|
296
|
+
slug
|
|
297
|
+
excerpt
|
|
298
|
+
coverImage {
|
|
299
|
+
url(transformation: {
|
|
300
|
+
image: {
|
|
301
|
+
resize: {
|
|
302
|
+
fit:crop,
|
|
303
|
+
width:585,
|
|
304
|
+
height:350
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
category
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
`, {
|
|
313
|
+
postId: post.id
|
|
314
|
+
});
|
|
315
|
+
return {
|
|
316
|
+
...data1,
|
|
317
|
+
next: data2.next?.[0],
|
|
318
|
+
previous: data2.previous?.[0],
|
|
319
|
+
latest: data2.latest
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
674
323
|
* Get a list of posts
|
|
675
324
|
*
|
|
676
325
|
* @param first take first X elements
|
|
677
326
|
* @param after after ID
|
|
678
|
-
*/
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
327
|
+
*/ async getPostsForBlog(first, after) {
|
|
328
|
+
const data = await this.fetchAPI(`
|
|
329
|
+
query Posts($first: Int!, $after: String, $stage: Stage!) {
|
|
330
|
+
posts(first: $first, after: $after, stage: $stage, where: {OR:[{featured: null}, {featured_not: true}]}, orderBy: date_DESC) {
|
|
331
|
+
id
|
|
332
|
+
title
|
|
333
|
+
slug
|
|
334
|
+
excerpt
|
|
335
|
+
coverImage {
|
|
336
|
+
url(transformation: {
|
|
337
|
+
image: {
|
|
338
|
+
resize: {
|
|
339
|
+
fit:crop,
|
|
340
|
+
width:585,
|
|
341
|
+
height:350
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
})
|
|
345
|
+
}
|
|
346
|
+
category
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
${!after ? `featured: posts(first: 3, stage: $stage, where: { featured: true }, orderBy: date_DESC) {
|
|
350
|
+
title
|
|
351
|
+
slug
|
|
352
|
+
excerpt
|
|
353
|
+
coverImage {
|
|
354
|
+
url(transformation: {
|
|
355
|
+
image: {
|
|
356
|
+
resize: {
|
|
357
|
+
fit:crop,
|
|
358
|
+
width:585,
|
|
359
|
+
height:350
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
}
|
|
364
|
+
category
|
|
365
|
+
}` : ''}
|
|
366
|
+
}
|
|
367
|
+
`, {
|
|
368
|
+
first,
|
|
369
|
+
after
|
|
370
|
+
});
|
|
371
|
+
return data;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
706
374
|
* Get a list of post slugs. This is used for getStaticPaths()
|
|
707
375
|
*
|
|
708
376
|
* @param first take first X elements
|
|
709
|
-
*/
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
];
|
|
722
|
-
case 1:
|
|
723
|
-
data = _state.sent();
|
|
724
|
-
return [
|
|
725
|
-
2,
|
|
726
|
-
data.posts.map(function(p) {
|
|
727
|
-
return p.slug;
|
|
728
|
-
})
|
|
729
|
-
];
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
})();
|
|
733
|
-
}
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
key: "getPagesSlugs",
|
|
737
|
-
value: /**
|
|
377
|
+
*/ async getPostsSlugs(first) {
|
|
378
|
+
const data = await this.fetchAPI(`
|
|
379
|
+
query PostsWithSlugs($first: Int!) {
|
|
380
|
+
posts(first: $first) {
|
|
381
|
+
slug
|
|
382
|
+
}
|
|
383
|
+
}`, {
|
|
384
|
+
first
|
|
385
|
+
});
|
|
386
|
+
return data.posts.map((p)=>p.slug);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
738
389
|
* Get a list of page slugs. This is used for getStaticPaths()
|
|
739
390
|
*
|
|
740
391
|
* @param first take first X elements
|
|
741
|
-
*/
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
];
|
|
754
|
-
case 1:
|
|
755
|
-
data = _state.sent();
|
|
756
|
-
return [
|
|
757
|
-
2,
|
|
758
|
-
data.pages.map(function(p) {
|
|
759
|
-
return p.slug;
|
|
760
|
-
})
|
|
761
|
-
];
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
})();
|
|
765
|
-
}
|
|
766
|
-
},
|
|
767
|
-
{
|
|
768
|
-
key: "getSitemap",
|
|
769
|
-
value: /**
|
|
392
|
+
*/ async getPagesSlugs(first) {
|
|
393
|
+
const data = await this.fetchAPI(`
|
|
394
|
+
query PagesSlugs($first: Int!) {
|
|
395
|
+
pages(first: $first) {
|
|
396
|
+
slug
|
|
397
|
+
}
|
|
398
|
+
}`, {
|
|
399
|
+
first
|
|
400
|
+
});
|
|
401
|
+
return data.pages.map((p)=>p.slug);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
770
404
|
* Get a list of entries for the sitemap
|
|
771
405
|
*
|
|
772
|
-
*/
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
};
|
|
799
|
-
})) || []))
|
|
800
|
-
];
|
|
801
|
-
}
|
|
802
|
-
});
|
|
803
|
-
})();
|
|
804
|
-
}
|
|
805
|
-
},
|
|
806
|
-
{
|
|
807
|
-
key: "getPage",
|
|
808
|
-
value: /**
|
|
406
|
+
*/ async getSitemap() {
|
|
407
|
+
const data = await this.fetchAPI(`
|
|
408
|
+
query Sitemap() {
|
|
409
|
+
pages() {
|
|
410
|
+
slug
|
|
411
|
+
updatedAt
|
|
412
|
+
}
|
|
413
|
+
posts {
|
|
414
|
+
slug
|
|
415
|
+
updatedAt
|
|
416
|
+
}
|
|
417
|
+
}`);
|
|
418
|
+
return [
|
|
419
|
+
...data.pages?.map((p)=>({
|
|
420
|
+
type: 'page',
|
|
421
|
+
slug: p.slug,
|
|
422
|
+
lastModifiedAt: p.updatedAt
|
|
423
|
+
})) || [],
|
|
424
|
+
...data.posts?.map((p)=>({
|
|
425
|
+
type: 'post',
|
|
426
|
+
slug: p.slug,
|
|
427
|
+
lastModifiedAt: p.updatedAt
|
|
428
|
+
})) || []
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
809
432
|
* Get a page
|
|
810
433
|
*
|
|
811
434
|
* @param slug slug of the page
|
|
812
|
-
*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
_data_page = data.page, sections = _data_page.sections, pageData = _object_without_properties(_data_page, [
|
|
834
|
-
"sections"
|
|
835
|
-
]);
|
|
836
|
-
return [
|
|
837
|
-
2,
|
|
838
|
-
_object_spread_props(_object_spread({}, pageData), {
|
|
839
|
-
sections: _this.fixSectionArrays(sections)
|
|
840
|
-
})
|
|
841
|
-
];
|
|
842
|
-
}
|
|
843
|
-
});
|
|
844
|
-
})();
|
|
435
|
+
*/ async getPage(slug) {
|
|
436
|
+
const data = await this.fetchAPI(`
|
|
437
|
+
query PageBySlug($slug: String!, $stage: Stage!) {
|
|
438
|
+
page(where: { slug: $slug }, stage: $stage) {
|
|
439
|
+
title
|
|
440
|
+
slug
|
|
441
|
+
seo {
|
|
442
|
+
title
|
|
443
|
+
description
|
|
444
|
+
keywords
|
|
445
|
+
image {
|
|
446
|
+
url(transformation: {
|
|
447
|
+
image: {
|
|
448
|
+
resize: {
|
|
449
|
+
fit: crop,
|
|
450
|
+
width: 1200,
|
|
451
|
+
height: 627
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
})
|
|
845
455
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
456
|
+
}
|
|
457
|
+
sections {
|
|
458
|
+
__typename
|
|
459
|
+
... on AvailableVehiclesForSubscription {
|
|
460
|
+
header
|
|
461
|
+
forceHeaderAlign
|
|
462
|
+
make
|
|
463
|
+
vehicleIDs
|
|
464
|
+
inquiryType
|
|
465
|
+
buttonText
|
|
466
|
+
buttonLink
|
|
467
|
+
}
|
|
468
|
+
... on CenteredHighlight {
|
|
469
|
+
header
|
|
470
|
+
forceHeaderAlign
|
|
471
|
+
description
|
|
472
|
+
inquiryType
|
|
473
|
+
buttonText
|
|
474
|
+
buttonLink
|
|
475
|
+
}
|
|
476
|
+
... on DualPhotoContentSection {
|
|
477
|
+
header
|
|
478
|
+
description
|
|
479
|
+
bigPhoto { url, width, height }
|
|
480
|
+
smallPhoto { url, width, height }
|
|
481
|
+
inquiryType
|
|
482
|
+
buttonText
|
|
483
|
+
buttonLink
|
|
484
|
+
}
|
|
485
|
+
... on DualPhotoHeading {
|
|
486
|
+
smallTitle
|
|
487
|
+
make
|
|
488
|
+
tagline
|
|
489
|
+
image1 { url, width, height }
|
|
490
|
+
image2 { url, width, height }
|
|
491
|
+
inquiryType
|
|
492
|
+
buttonText
|
|
493
|
+
buttonLink
|
|
494
|
+
}
|
|
495
|
+
... on FullWidthGallery {
|
|
496
|
+
images { url, width, height }
|
|
497
|
+
mobileImages { url, width, height }
|
|
498
|
+
}
|
|
499
|
+
... on Reviews {
|
|
500
|
+
header
|
|
501
|
+
forceHeaderAlign
|
|
502
|
+
images { url, width, height }
|
|
503
|
+
names
|
|
504
|
+
vehicles
|
|
505
|
+
reviews
|
|
506
|
+
inquiryType
|
|
507
|
+
buttonText
|
|
508
|
+
buttonLink
|
|
509
|
+
}
|
|
510
|
+
... on VehicleShowcase {
|
|
511
|
+
header
|
|
512
|
+
forceHeaderAlign
|
|
513
|
+
topTitles
|
|
514
|
+
secondaryTitles
|
|
515
|
+
photos { url, width, height }
|
|
516
|
+
contents { raw }
|
|
517
|
+
inquiryType
|
|
518
|
+
buttonText
|
|
519
|
+
buttonLink
|
|
520
|
+
}
|
|
521
|
+
... on LineSeparator {
|
|
522
|
+
id
|
|
523
|
+
}
|
|
524
|
+
... on HeroHeading {
|
|
525
|
+
header
|
|
526
|
+
forceHeaderAlign
|
|
527
|
+
subHeader
|
|
528
|
+
description
|
|
529
|
+
_dedupeHeroHeading_image: image { url, width, height }
|
|
530
|
+
mobileImage { url, width, height }
|
|
531
|
+
inquiryType
|
|
532
|
+
buttonText
|
|
533
|
+
buttonLink
|
|
534
|
+
buttonVariant
|
|
535
|
+
textColor
|
|
536
|
+
}
|
|
537
|
+
... on RichTextSection {
|
|
538
|
+
header
|
|
539
|
+
forceHeaderAlign
|
|
540
|
+
content { raw }
|
|
541
|
+
inquiryType
|
|
542
|
+
buttonText
|
|
543
|
+
buttonLink
|
|
544
|
+
}
|
|
545
|
+
... on ImageStepFlows {
|
|
546
|
+
images { url, width, height }
|
|
547
|
+
inquiryType
|
|
548
|
+
buttonText
|
|
549
|
+
buttonLink
|
|
550
|
+
}
|
|
551
|
+
... on TermsCondition {
|
|
552
|
+
header
|
|
553
|
+
forceHeaderAlign
|
|
554
|
+
content { raw }
|
|
555
|
+
inquiryType
|
|
556
|
+
buttonText
|
|
557
|
+
buttonLink
|
|
558
|
+
}
|
|
559
|
+
... on MultiplePhotoCaption {
|
|
560
|
+
header
|
|
561
|
+
forceHeaderAlign
|
|
562
|
+
titles
|
|
563
|
+
descriptions { raw }
|
|
564
|
+
useIconSize
|
|
565
|
+
photos { url, width, height }
|
|
566
|
+
inquiryType
|
|
567
|
+
buttonText
|
|
568
|
+
buttonLink
|
|
569
|
+
}
|
|
570
|
+
... on SinglePhotoContent {
|
|
571
|
+
header
|
|
572
|
+
content { raw }
|
|
573
|
+
image { url, width, height }
|
|
574
|
+
orientation
|
|
575
|
+
inquiryType
|
|
576
|
+
buttonText
|
|
577
|
+
buttonLink
|
|
578
|
+
}
|
|
579
|
+
... on DualBigImage {
|
|
580
|
+
header
|
|
581
|
+
forceHeaderAlign
|
|
582
|
+
content { raw }
|
|
583
|
+
leftImage { url, width, height }
|
|
584
|
+
leftTitle
|
|
585
|
+
leftCaption { raw }
|
|
586
|
+
leftDarkBackground
|
|
587
|
+
rightImage { url, width, height }
|
|
588
|
+
rightTitle
|
|
589
|
+
rightCaption { raw }
|
|
590
|
+
rightDarkBackground
|
|
591
|
+
inquiryType
|
|
592
|
+
buttonText
|
|
593
|
+
buttonLink
|
|
594
|
+
}
|
|
595
|
+
... on PhotoCarousel {
|
|
596
|
+
header
|
|
597
|
+
forceHeaderAlign
|
|
598
|
+
photos { url, width, height }
|
|
599
|
+
titles
|
|
600
|
+
hrefs
|
|
601
|
+
inquiryType
|
|
602
|
+
buttonText
|
|
603
|
+
buttonLink
|
|
604
|
+
}
|
|
605
|
+
... on TextPageBreak {
|
|
606
|
+
headers
|
|
607
|
+
aligns
|
|
608
|
+
bgColor
|
|
609
|
+
textColor
|
|
610
|
+
}
|
|
611
|
+
... on BigTextColumns {
|
|
612
|
+
header
|
|
613
|
+
forceHeaderAlign
|
|
614
|
+
content { raw }
|
|
615
|
+
bigTitles
|
|
616
|
+
smallTitles
|
|
617
|
+
descriptions { raw }
|
|
618
|
+
inquiryType
|
|
619
|
+
buttonText
|
|
620
|
+
buttonLink
|
|
621
|
+
}
|
|
622
|
+
... on PhotoWithTextBox {
|
|
623
|
+
header
|
|
624
|
+
forceHeaderAlign
|
|
625
|
+
content { raw }
|
|
626
|
+
orientation
|
|
627
|
+
image { url, width, height }
|
|
628
|
+
isLightBackground
|
|
629
|
+
inquiryType
|
|
630
|
+
buttonText
|
|
631
|
+
buttonLink
|
|
632
|
+
}
|
|
633
|
+
... on PhotoGrid {
|
|
634
|
+
header
|
|
635
|
+
forceHeaderAlign
|
|
636
|
+
images { url, width, height }
|
|
637
|
+
inquiryType
|
|
638
|
+
buttonText
|
|
639
|
+
buttonLink
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}`, {
|
|
644
|
+
slug
|
|
645
|
+
});
|
|
646
|
+
if (!data.page) {
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
const { sections, ...pageData } = data.page;
|
|
650
|
+
return {
|
|
651
|
+
...pageData,
|
|
652
|
+
sections: this.fixSectionArrays(sections)
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
fixSectionArrays(sections) {
|
|
656
|
+
const newSections = [];
|
|
657
|
+
for (const section of sections){
|
|
658
|
+
const fixedSection = cloneDeep(section);
|
|
659
|
+
for (const key of Object.keys(fixedSection)){
|
|
660
|
+
if (key.startsWith('_dedupe')) {
|
|
661
|
+
const parts = key.split('_');
|
|
662
|
+
// Remove the first two
|
|
663
|
+
parts.shift();
|
|
664
|
+
parts.shift();
|
|
665
|
+
fixedSection[parts.join('')] = fixedSection[key];
|
|
666
|
+
// @ts-expect-error // TODO
|
|
667
|
+
delete fixedSection[key];
|
|
899
668
|
}
|
|
900
|
-
return newSections;
|
|
901
669
|
}
|
|
670
|
+
newSections.push(this.#sectionHandlers[section.__typename] ? this.#sectionHandlers[section.__typename](fixedSection) : fixedSection);
|
|
902
671
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
672
|
+
return newSections;
|
|
673
|
+
}
|
|
674
|
+
}
|