@mjhls/mjh-framework 1.0.1065 → 1.0.1067-featureUpdate
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/cjs/Feature.js +419 -8
- package/dist/cjs/View.js +3 -4
- package/dist/cjs/getQuery.js +1 -1
- package/dist/esm/Feature.js +419 -8
- package/dist/esm/View.js +3 -4
- package/dist/esm/getQuery.js +1 -1
- package/package.json +2 -1
package/dist/cjs/Feature.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var urlFor = require('./urlFor.js');
|
|
5
|
-
var main = require('./main-ae8472f3.js');
|
|
6
5
|
var Carousel = require('react-bootstrap/Carousel');
|
|
7
6
|
require('./slicedToArray-067dd3bc.js');
|
|
8
7
|
require('./_commonjsHelpers-06173234.js');
|
|
@@ -16,6 +15,408 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
15
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
16
|
var Carousel__default = /*#__PURE__*/_interopDefaultLegacy(Carousel);
|
|
18
17
|
|
|
18
|
+
function _inheritsLoose(subClass, superClass) {
|
|
19
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
20
|
+
subClass.prototype.constructor = subClass;
|
|
21
|
+
subClass.__proto__ = superClass;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _getPrototypeOf(o) {
|
|
25
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
26
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
27
|
+
};
|
|
28
|
+
return _getPrototypeOf(o);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _setPrototypeOf(o, p) {
|
|
32
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
33
|
+
o.__proto__ = p;
|
|
34
|
+
return o;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return _setPrototypeOf(o, p);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _isNativeReflectConstruct() {
|
|
41
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
42
|
+
if (Reflect.construct.sham) return false;
|
|
43
|
+
if (typeof Proxy === "function") return true;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
|
47
|
+
return true;
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function _construct(Parent, args, Class) {
|
|
54
|
+
if (_isNativeReflectConstruct()) {
|
|
55
|
+
_construct = Reflect.construct;
|
|
56
|
+
} else {
|
|
57
|
+
_construct = function _construct(Parent, args, Class) {
|
|
58
|
+
var a = [null];
|
|
59
|
+
a.push.apply(a, args);
|
|
60
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
61
|
+
var instance = new Constructor();
|
|
62
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
63
|
+
return instance;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return _construct.apply(null, arguments);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _isNativeFunction(fn) {
|
|
71
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _wrapNativeSuper(Class) {
|
|
75
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
76
|
+
|
|
77
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
78
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
79
|
+
|
|
80
|
+
if (typeof Class !== "function") {
|
|
81
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (typeof _cache !== "undefined") {
|
|
85
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
86
|
+
|
|
87
|
+
_cache.set(Class, Wrapper);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function Wrapper() {
|
|
91
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
95
|
+
constructor: {
|
|
96
|
+
value: Wrapper,
|
|
97
|
+
enumerable: false,
|
|
98
|
+
writable: true,
|
|
99
|
+
configurable: true
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return _wrapNativeSuper(Class);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Error type thrown when the library fails to resolve a value, such as an asset ID,
|
|
110
|
+
* filename or project ID/dataset information.
|
|
111
|
+
*
|
|
112
|
+
* The `input` property holds the value passed as the input, which failed to be
|
|
113
|
+
* resolved to something meaningful.
|
|
114
|
+
*/
|
|
115
|
+
var UnresolvableError = /*#__PURE__*/function (_Error) {
|
|
116
|
+
_inheritsLoose(UnresolvableError, _Error);
|
|
117
|
+
|
|
118
|
+
function UnresolvableError(inputSource, message) {
|
|
119
|
+
var _this;
|
|
120
|
+
|
|
121
|
+
if (message === void 0) {
|
|
122
|
+
message = 'Failed to resolve asset ID from source';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
_this = _Error.call(this, message) || this;
|
|
126
|
+
_this.unresolvable = true;
|
|
127
|
+
_this.input = inputSource;
|
|
128
|
+
return _this;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return UnresolvableError;
|
|
132
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
var cdnUrl = 'https://cdn.sanity.io';
|
|
138
|
+
/**
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
var fileAssetFilenamePattern = /^([a-zA-Z0-9_]{24,40}|[a-f0-9]{40})+\.[a-z0-9]+$/;
|
|
143
|
+
/**
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
var imageAssetFilenamePattern = /^([a-zA-Z0-9_]{24,40}|[a-f0-9]{40})-\d+x\d+\.[a-z0-9]+$/;
|
|
148
|
+
/**
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
var pathPattern = /^(images|files)\/([a-z0-9]+)\/([a-z0-9][-\w]*)\//;
|
|
153
|
+
/**
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
var idPattern = /^(?:image-[a-zA-Z0-9_]+-\d+x\d+-[a-z0-9]+|file-[a-zA-Z0-9_]+-[a-z0-9]+)$/;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Checks whether or not the given source is a Sanity reference
|
|
161
|
+
* (an object containing _ref string key)
|
|
162
|
+
*
|
|
163
|
+
* @param ref - Possible reference
|
|
164
|
+
* @returns Whether or not the passed object is a reference
|
|
165
|
+
*/
|
|
166
|
+
function isReference(ref) {
|
|
167
|
+
return isObject(ref) && typeof ref._ref === 'string';
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Checks whether or not the given source is an asset ID stub
|
|
171
|
+
* (an object containing an `_id` property)
|
|
172
|
+
*
|
|
173
|
+
* @param stub - Possible asset id stub
|
|
174
|
+
* @returns Whether or not the passed object is an object id stub
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
function isAssetIdStub(stub) {
|
|
178
|
+
return isObject(stub) && typeof stub._id === 'string';
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Checks whether or not the given source is an asset path stub
|
|
182
|
+
* (an object containing a `path` property)
|
|
183
|
+
*
|
|
184
|
+
* @param stub - Possible asset path stub
|
|
185
|
+
* @returns Whether or not the passed object is an object path stub
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
function isAssetPathStub(stub) {
|
|
189
|
+
return isObject(stub) && typeof stub.path === 'string';
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Checks whether or not the given source is an asset URL stub
|
|
193
|
+
* (an object containing a `url` property)
|
|
194
|
+
*
|
|
195
|
+
* @param stub - Possible asset url stub
|
|
196
|
+
* @returns Whether or not the passed object is an object url stub
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
function isAssetUrlStub(stub) {
|
|
200
|
+
return isObject(stub) && typeof stub.url === 'string';
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Checks whether or not the given source is an asset object stub
|
|
204
|
+
*
|
|
205
|
+
* @param stub - Possible asset object stub
|
|
206
|
+
* @returns Whether or not the passed object is an object stub
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
function isAssetObjectStub(stub) {
|
|
210
|
+
var item = stub;
|
|
211
|
+
return isObject(item) && item.asset && typeof item.asset === 'object';
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Checks whether or not the passed object is an object (and not `null`)
|
|
215
|
+
*
|
|
216
|
+
* @param obj Item to check whether or not is an object
|
|
217
|
+
* @returns Whether or not `obj` is an object
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
function isObject(obj) {
|
|
222
|
+
return obj !== null && !Array.isArray(obj) && typeof obj === 'object';
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Strips the CDN URL and query params from a URL, eg:
|
|
226
|
+
* `https://cdn.sanity.io/images/project/dataset/filename-200x200.jpg?foo=bar` =>
|
|
227
|
+
* `images/project/dataset/filename-200x200.jpg`
|
|
228
|
+
*
|
|
229
|
+
* @param url - URL to get path name from
|
|
230
|
+
* @returns The path of a CDN URL
|
|
231
|
+
* @throws If URL is not a valid Sanity asset URL
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
function getUrlPath(url) {
|
|
235
|
+
if (pathPattern.test(url)) {
|
|
236
|
+
// Already just a path
|
|
237
|
+
return url;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (!url.startsWith(cdnUrl + "/")) {
|
|
241
|
+
throw new UnresolvableError("Failed to resolve path from URL \"" + url + "\"");
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
var qsPos = url.indexOf('?');
|
|
245
|
+
var toIndex = qsPos === -1 ? undefined : qsPos;
|
|
246
|
+
return url.slice(cdnUrl.length + 1, toIndex);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* @internal
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
var exampleImageId = 'image-027401f31c3ac1e6d78c5d539ccd1beff72b9b11-2000x3000-jpg';
|
|
253
|
+
/**
|
|
254
|
+
* Parses a Sanity image asset document ID into individual parts (type, id, extension, width, height)
|
|
255
|
+
*
|
|
256
|
+
* @param documentId - Image asset document ID to parse into named parts
|
|
257
|
+
* @returns Object of named properties
|
|
258
|
+
* @throws If document ID invalid
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
function parseImageAssetId(documentId) {
|
|
262
|
+
var _documentId$split2 = documentId.split('-'),
|
|
263
|
+
assetId = _documentId$split2[1],
|
|
264
|
+
dimensionString = _documentId$split2[2],
|
|
265
|
+
extension = _documentId$split2[3];
|
|
266
|
+
|
|
267
|
+
var _split$map = (dimensionString || '').split('x').map(Number),
|
|
268
|
+
width = _split$map[0],
|
|
269
|
+
height = _split$map[1];
|
|
270
|
+
|
|
271
|
+
if (!assetId || !dimensionString || !extension || !(width > 0) || !(height > 0)) {
|
|
272
|
+
throw new Error("Malformed asset ID '" + documentId + "'. Expected an id like \"" + exampleImageId + "\".");
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
type: 'image',
|
|
277
|
+
assetId: assetId,
|
|
278
|
+
width: width,
|
|
279
|
+
height: height,
|
|
280
|
+
extension: extension
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Returns the width, height and aspect ratio of a passed image asset, from any
|
|
286
|
+
* inferrable structure (id, url, path, asset document, image object etc)
|
|
287
|
+
*
|
|
288
|
+
* @param src - Input source (image object, asset, reference, id, url, path)
|
|
289
|
+
* @returns Object with width, height and aspect ratio properties
|
|
290
|
+
*
|
|
291
|
+
* @throws {@link UnresolvableError}
|
|
292
|
+
* Throws if passed image source could not be resolved to an asset ID
|
|
293
|
+
*/
|
|
294
|
+
|
|
295
|
+
function getImageDimensions(src) {
|
|
296
|
+
var imageId = getAssetDocumentId(src);
|
|
297
|
+
|
|
298
|
+
var _parseImageAssetId = parseImageAssetId(imageId),
|
|
299
|
+
width = _parseImageAssetId.width,
|
|
300
|
+
height = _parseImageAssetId.height;
|
|
301
|
+
|
|
302
|
+
var aspectRatio = width / height;
|
|
303
|
+
return {
|
|
304
|
+
width: width,
|
|
305
|
+
height: height,
|
|
306
|
+
aspectRatio: aspectRatio
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Tries to resolve the asset document ID from any inferrable structure
|
|
311
|
+
*
|
|
312
|
+
* @param src - Input source (image/file object, asset, reference, id, url, path)
|
|
313
|
+
* @returns The asset document ID
|
|
314
|
+
*
|
|
315
|
+
* @throws {@link UnresolvableError}
|
|
316
|
+
* Throws if passed asset source could not be resolved to an asset document ID
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
function getAssetDocumentId(src) {
|
|
320
|
+
var source = isAssetObjectStub(src) ? src.asset : src;
|
|
321
|
+
var id = '';
|
|
322
|
+
|
|
323
|
+
if (typeof source === 'string') {
|
|
324
|
+
id = getIdFromString(source);
|
|
325
|
+
} else if (isReference(source)) {
|
|
326
|
+
id = source._ref;
|
|
327
|
+
} else if (isAssetIdStub(source)) {
|
|
328
|
+
id = source._id;
|
|
329
|
+
} else if (isAssetPathStub(source)) {
|
|
330
|
+
id = idFromUrl(cdnUrl + "/" + source.path);
|
|
331
|
+
} else if (isAssetUrlStub(source)) {
|
|
332
|
+
id = idFromUrl(source.url);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
var hasId = id && idPattern.test(id);
|
|
336
|
+
|
|
337
|
+
if (!hasId) {
|
|
338
|
+
throw new UnresolvableError(src);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return id;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Tries to cooerce a string (ID, URL or path) to an image asset ID
|
|
345
|
+
*
|
|
346
|
+
* @param str - Input string (ID, URL or path)
|
|
347
|
+
* @returns string
|
|
348
|
+
*
|
|
349
|
+
*
|
|
350
|
+
* @throws {@link UnresolvableError}
|
|
351
|
+
* Throws if passed image source could not be resolved to an asset ID
|
|
352
|
+
*/
|
|
353
|
+
|
|
354
|
+
function getIdFromString(str) {
|
|
355
|
+
if (idPattern.test(str)) {
|
|
356
|
+
// Already an ID
|
|
357
|
+
return str;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (str.indexOf(cdnUrl + "/images") === 0 || str.indexOf(cdnUrl + "/files") === 0) {
|
|
361
|
+
// Full URL
|
|
362
|
+
return idFromUrl(str);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (pathPattern.test(str)) {
|
|
366
|
+
// Path
|
|
367
|
+
return idFromUrl(cdnUrl + "/" + str);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (isFileAssetFilename(str)) {
|
|
371
|
+
// Just a filename (projectId/dataset irrelevant: just need asset ID)
|
|
372
|
+
return idFromUrl(cdnUrl + "/files/a/b/" + str);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (isImageAssetFilename(str)) {
|
|
376
|
+
// Just a filename (projectId/dataset irrelevant: just need asset ID)
|
|
377
|
+
return idFromUrl(cdnUrl + "/images/a/b/" + str);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
throw new UnresolvableError(str);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Converts from a full asset URL to just the asset document ID
|
|
384
|
+
*
|
|
385
|
+
* @param url - A full asset URL to convert
|
|
386
|
+
* @returns string
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
function idFromUrl(url) {
|
|
390
|
+
var path = getUrlPath(url);
|
|
391
|
+
|
|
392
|
+
var _path$split = path.split('/'),
|
|
393
|
+
type = _path$split[0],
|
|
394
|
+
fileName = _path$split[3];
|
|
395
|
+
|
|
396
|
+
var prefix = type.replace(/s$/, '');
|
|
397
|
+
return prefix + "-" + fileName.replace(/\./g, '-');
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Returns whether or not the passed filename is a valid image asset filename
|
|
401
|
+
*
|
|
402
|
+
* @param filename - Filename to validate
|
|
403
|
+
* @returns Whether or not the filename is an image asset filename
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
function isImageAssetFilename(filename) {
|
|
407
|
+
return imageAssetFilenamePattern.test(filename);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Returns whether or not the passed filename is a valid file asset filename
|
|
411
|
+
*
|
|
412
|
+
* @param filename - Filename to validate
|
|
413
|
+
* @returns Whether or not the filename is a file asset filename
|
|
414
|
+
*/
|
|
415
|
+
|
|
416
|
+
function isFileAssetFilename(filename) {
|
|
417
|
+
return fileAssetFilenamePattern.test(filename);
|
|
418
|
+
}
|
|
419
|
+
|
|
19
420
|
/* eslint-disable camelcase */
|
|
20
421
|
// Feature query to be used
|
|
21
422
|
// const featureQuery = `*[_type == 'feature' && is_active == true && feature_url == "/"] | order(_updatedAt asc)[0..5]{
|
|
@@ -40,11 +441,18 @@ var Feature = function Feature(props) {
|
|
|
40
441
|
return false;
|
|
41
442
|
};
|
|
42
443
|
|
|
444
|
+
var featureImgDimensions = function featureImgDimensions(image) {
|
|
445
|
+
if (image) {
|
|
446
|
+
var dims = getImageDimensions(image);
|
|
447
|
+
return { width: dims.width, height: dims.height };
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
|
|
43
451
|
// image width updated.
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
}
|
|
452
|
+
// let imageWidth = 900
|
|
453
|
+
// if (isMobileOnly) {
|
|
454
|
+
// imageWidth = 225
|
|
455
|
+
// }
|
|
48
456
|
|
|
49
457
|
var renderUrl = function renderUrl(feature_link, feature_title, feature_body) {
|
|
50
458
|
if (checkUrlIsExternal(feature_link)) {
|
|
@@ -104,7 +512,8 @@ var Feature = function Feature(props) {
|
|
|
104
512
|
hide_title_body = feature.hide_title_body,
|
|
105
513
|
feature_img = feature.feature_img,
|
|
106
514
|
feature_alt = feature.feature_alt,
|
|
107
|
-
feature_link = feature.feature_link
|
|
515
|
+
feature_link = feature.feature_link,
|
|
516
|
+
feature_contain = feature.feature_contain;
|
|
108
517
|
|
|
109
518
|
return React__default["default"].createElement(
|
|
110
519
|
Carousel__default["default"].Item,
|
|
@@ -112,9 +521,11 @@ var Feature = function Feature(props) {
|
|
|
112
521
|
return openLink(feature_link);
|
|
113
522
|
} },
|
|
114
523
|
React__default["default"].createElement('img', {
|
|
115
|
-
style: { maxHeight: '375px',
|
|
524
|
+
style: { maxHeight: '375px', objectFit: feature_contain ? 'contain' : 'cover', cursor: 'pointer' },
|
|
116
525
|
className: 'd-block w-100',
|
|
117
|
-
src: urlFor({ client: client, source: feature_img, imageWidth:
|
|
526
|
+
src: urlFor({ client: client, source: feature_img, imageWidth: featureImgDimensions(feature_img).width }),
|
|
527
|
+
width: featureImgDimensions(feature_img).width,
|
|
528
|
+
height: featureImgDimensions(feature_img).height,
|
|
118
529
|
alt: feature_alt
|
|
119
530
|
}),
|
|
120
531
|
!hide_title_body && React__default["default"].createElement(
|
package/dist/cjs/View.js
CHANGED
|
@@ -32,7 +32,6 @@ var disqusReact = require('disqus-react');
|
|
|
32
32
|
var Schema = require('./Schema.js');
|
|
33
33
|
var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
|
|
34
34
|
var PixelTracking = require('./PixelTracking.js');
|
|
35
|
-
require('./Segment.js');
|
|
36
35
|
var keys = require('./keys-e982b3fa.js');
|
|
37
36
|
var index_es = require('./index.es-1ab8dda7.js');
|
|
38
37
|
var index = require('./index-7435b964.js');
|
|
@@ -51,6 +50,7 @@ require('react-share');
|
|
|
51
50
|
require('react-bootstrap');
|
|
52
51
|
require('./index-187c967e.js');
|
|
53
52
|
require('./Beam.js');
|
|
53
|
+
require('./Segment.js');
|
|
54
54
|
require('./brightcove-react-player-loader.es-4c7825a1.js');
|
|
55
55
|
require('./_object-to-array-9337ba83.js');
|
|
56
56
|
require('react-bootstrap/Modal');
|
|
@@ -586,9 +586,8 @@ var Recommended = function Recommended(props) {
|
|
|
586
586
|
|
|
587
587
|
case 11:
|
|
588
588
|
_context.next = 13;
|
|
589
|
-
return fetch('/api/getSegmentProfile', {
|
|
590
|
-
method: '
|
|
591
|
-
body: stringify._JSON$stringify({ anonymousId: anonymousId })
|
|
589
|
+
return fetch('/api/getSegmentProfile?anonymousId=' + anonymousId, {
|
|
590
|
+
method: 'GET'
|
|
592
591
|
});
|
|
593
592
|
|
|
594
593
|
case 13:
|
package/dist/cjs/getQuery.js
CHANGED
|
@@ -11,7 +11,7 @@ var getQuery = function getQuery(type) {
|
|
|
11
11
|
switch (type) {
|
|
12
12
|
// quiz video series and slideshow
|
|
13
13
|
case 'related':
|
|
14
|
-
return '*[\n _type == "article"\n && defined(title)\n && defined(url)\n && !(_id in path("drafts.**"))\n && is_visible == true\n && defined(published) \n && dateTime(published) <= dateTime(now())\n && passwordLock!=true\n && isHealthcareProfessional != true\n && taxonomyMapping[]._ref in $taxonomy\n && taxonomyMapping[].disableAds != \'true\'\n && contentCategory->.name != \'Poll\'\n && contentCategory->.name != \'Slideshows\'\n && contentCategory->.disableAds != \'true\'\n && ExcludeFromInfiniteScroll !=true\n && url.current != $url\n && !defined(body[].videos)\n && !defined(body[].quizzes)\n && !defined(body[].slides)\n && !defined(body[].articles)\n ' + conditions + '\n ]| order(published desc)[' + (articleCount ? articleCount : '$index') + ']{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n abstract,\n ...,\n passwordLock,\n password,\n "authorDetails": authorMapping[]->{ displayName, firstName, lastName, url, profileImage, biography, showSocialShare },\n body[] {\n ...,\n asset->,\n images[]{\n ...,\n asset->\n },\n content[]{\n ...,\n asset->\n },\n videos[]{\n ...,\n thumbnail{\n _type,\n asset->\n }\n },\n response[]{\n ...,\n asset->\n },\n quizzes[]{\n ...,\n answer[]{\n ...,\n asset->\n },\n question[]{\n ...,\n asset->\n }\n },\n poster {\n _type,\n asset->\n },\n slides[]{\n ...,\n slideshowImage{\n ...,\n asset->\n }\n },\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n }\n },\n \'category\':contentCategory->{\n name,\n disableAds\n },\n \'content_placement\': taxonomyMapping[]-> {\n
|
|
14
|
+
return '*[\n _type == "article"\n && defined(title)\n && defined(url)\n && !(_id in path("drafts.**"))\n && is_visible == true\n && defined(published) \n && dateTime(published) <= dateTime(now())\n && passwordLock!=true\n && isHealthcareProfessional != true\n && taxonomyMapping[]._ref in $taxonomy\n && taxonomyMapping[].disableAds != \'true\'\n && contentCategory->.name != \'Poll\'\n && contentCategory->.name != \'Slideshows\'\n && contentCategory->.disableAds != \'true\'\n && ExcludeFromInfiniteScroll !=true\n && url.current != $url\n && !defined(body[].videos)\n && !defined(body[].quizzes)\n && !defined(body[].slides)\n && !defined(body[].articles)\n ' + conditions + '\n ]| order(published desc)[' + (articleCount ? articleCount : '$index') + ']{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n abstract,\n ...,\n passwordLock,\n password,\n "authorDetails": authorMapping[]->{ displayName, firstName, lastName, url, profileImage, biography, showSocialShare },\n body[] {\n ...,\n asset->,\n images[]{\n ...,\n asset->\n },\n content[]{\n ...,\n asset->\n },\n videos[]{\n ...,\n thumbnail{\n _type,\n asset->\n }\n },\n response[]{\n ...,\n asset->\n },\n quizzes[]{\n ...,\n answer[]{\n ...,\n asset->\n },\n question[]{\n ...,\n asset->\n }\n },\n poster {\n _type,\n asset->\n },\n slides[]{\n ...,\n slideshowImage{\n ...,\n asset->\n }\n },\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n }\n },\n \'category\':contentCategory->{\n name,\n disableAds\n },\n \'content_placement\': taxonomyMapping[]-> {\n ...,\n \'ancestor\': parent->parent->identifier,\n \'parent\': parent->identifier,\n \'name\': name,\n \'path\': identifier,\n showSocialShare,\n pixelTrackingCode->\n },\n documentGroup-> {\n name,\n thumbnail,\n hideThumbnail,\n parent->{...,parent->},\n isShow,\n showSocialShare,\n \'path\': identifier.current,\n adTargetingURL,\n hideSeriesSlider,\n pixelTrackingCode->\n },\n documentGroupMapping[]-> {\n _id,\n name,\n thumbnail,\n parent->{...,parent->},\n isShow,\n showSocialShare,\n \'path\': identifier.current,\n adTargetingURL,\n hideSeriesSlider,\n pixelTrackingCode->\n },\n \'issue\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.issueGroup._ref][0] {\n name,\n \'path\': identifier.current,\n show_download_ris_button,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current,\n show_download_ris_button,\n },\n \'url\' : pdf.asset-> url,\n \'pdf\': pdf.asset->,\n isbn_issn,\n abbreviatedJournal,\n }\n }';
|
|
15
15
|
case 'article':
|
|
16
16
|
return '*[\n _type == "article"\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible != false\n && url.current == $url\n ' + conditions + '\n ][0]{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n abstract,\n ...,\n passwordLock,\n password,\n disableNativeAds,\n issueGroup-> { _id, name, identifier, showIssueNameOnly, showPageNumber, risMapping, parent-> },\n "authorDetails": authorMapping[]->{ displayName, firstName, lastName, url, profileImage, biography, showSocialShare },\n body[] {\n ...,\n asset->,\n images[]{\n ...,\n asset->\n },\n content[]{\n ...,\n asset->\n },\n videos[]{\n ...,\n thumbnail{\n _type,\n asset->\n }\n },\n response[]{\n ...,\n asset->\n },\n quizzes[]{\n ...,\n answer[]{\n ...,\n asset->\n },\n question[]{\n ...,\n asset->\n }\n },\n poster {\n _type,\n asset->\n },\n slides[]{\n ...,\n slideshowImage{\n ...,\n asset->\n }\n },\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n },\n medias[]{\n ...,\n upload_doc {\n _type,\n asset-> \n },\n poster {\n _type,\n asset-> \n }\n },\n articles[]{\n ...,\n thumbnail{\n ...,\n asset-> \n },\n "authorDetails": authorMapping[]->{ displayName, firstName, lastName, url, profileImage, biography, showSocialShare },\n text[]{\n ...,\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n },\n }\n }\n },\n \'content_placement\': taxonomyMapping[]-> {\n ...,\n \'ancestor\': parent->parent->identifier,\n \'parent\': parent->identifier,\n \'name\': name,\n \'path\': identifier,\n showSocialShare,\n pixelTrackingCode->\n },\n documentGroup-> {\n _id,\n name,\n thumbnail,\n hideThumbnail,\n parent->{...,parent->},\n isShow,\n isSeries,\n disableEpisodeNumber,\n excludeRelatedContents,\n showSocialShare,\n \'path\': identifier.current,\n adTargetingURL,\n hideSeriesSlider,\n pixelTrackingCode->\n },\n documentGroupMapping[]-> {\n _id,\n name,\n thumbnail,\n isSeries,\n disableEpisodeNumber,\n parent->{...,parent->},\n isShow,\n showSocialShare,\n excludeRelatedContents,\n \'path\': identifier.current,\n hideSeriesSlider,\n pixelTrackingCode->\n },\n \'category\':contentCategory->{\n name,\n disableAds\n },\n \'issue\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.issueGroup._ref][0] {\n name,\n volume,\n year,\n \'issueNumber\': number,\n \'articleSource\': source,\n \'path\': identifier.current,\n show_download_ris_button,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current,\n show_download_ris_button,\n },\n \'url\' : pdf.asset-> url,\n \'pdf\': pdf.asset->,\n isbn_issn,\n abbreviatedJournal,\n }\n\n }';
|
|
17
17
|
case 'publication':
|
package/dist/esm/Feature.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import urlFor from './urlFor.js';
|
|
3
|
-
import { m as main_43 } from './main-754d4992.js';
|
|
4
3
|
import Carousel from 'react-bootstrap/Carousel';
|
|
5
4
|
import './slicedToArray-6ebcbfea.js';
|
|
6
5
|
import './_commonjsHelpers-0c4b6f40.js';
|
|
@@ -9,6 +8,408 @@ import './core.get-iterator-method-ea258bb1.js';
|
|
|
9
8
|
import './extends-1559c147.js';
|
|
10
9
|
import './index-3f5c03b2.js';
|
|
11
10
|
|
|
11
|
+
function _inheritsLoose(subClass, superClass) {
|
|
12
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
13
|
+
subClass.prototype.constructor = subClass;
|
|
14
|
+
subClass.__proto__ = superClass;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _getPrototypeOf(o) {
|
|
18
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
19
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
20
|
+
};
|
|
21
|
+
return _getPrototypeOf(o);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _setPrototypeOf(o, p) {
|
|
25
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
26
|
+
o.__proto__ = p;
|
|
27
|
+
return o;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return _setPrototypeOf(o, p);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _isNativeReflectConstruct() {
|
|
34
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
35
|
+
if (Reflect.construct.sham) return false;
|
|
36
|
+
if (typeof Proxy === "function") return true;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
|
40
|
+
return true;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function _construct(Parent, args, Class) {
|
|
47
|
+
if (_isNativeReflectConstruct()) {
|
|
48
|
+
_construct = Reflect.construct;
|
|
49
|
+
} else {
|
|
50
|
+
_construct = function _construct(Parent, args, Class) {
|
|
51
|
+
var a = [null];
|
|
52
|
+
a.push.apply(a, args);
|
|
53
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
54
|
+
var instance = new Constructor();
|
|
55
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
56
|
+
return instance;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return _construct.apply(null, arguments);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _isNativeFunction(fn) {
|
|
64
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function _wrapNativeSuper(Class) {
|
|
68
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
69
|
+
|
|
70
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
71
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
72
|
+
|
|
73
|
+
if (typeof Class !== "function") {
|
|
74
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (typeof _cache !== "undefined") {
|
|
78
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
79
|
+
|
|
80
|
+
_cache.set(Class, Wrapper);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function Wrapper() {
|
|
84
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
88
|
+
constructor: {
|
|
89
|
+
value: Wrapper,
|
|
90
|
+
enumerable: false,
|
|
91
|
+
writable: true,
|
|
92
|
+
configurable: true
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return _wrapNativeSuper(Class);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Error type thrown when the library fails to resolve a value, such as an asset ID,
|
|
103
|
+
* filename or project ID/dataset information.
|
|
104
|
+
*
|
|
105
|
+
* The `input` property holds the value passed as the input, which failed to be
|
|
106
|
+
* resolved to something meaningful.
|
|
107
|
+
*/
|
|
108
|
+
var UnresolvableError = /*#__PURE__*/function (_Error) {
|
|
109
|
+
_inheritsLoose(UnresolvableError, _Error);
|
|
110
|
+
|
|
111
|
+
function UnresolvableError(inputSource, message) {
|
|
112
|
+
var _this;
|
|
113
|
+
|
|
114
|
+
if (message === void 0) {
|
|
115
|
+
message = 'Failed to resolve asset ID from source';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
_this = _Error.call(this, message) || this;
|
|
119
|
+
_this.unresolvable = true;
|
|
120
|
+
_this.input = inputSource;
|
|
121
|
+
return _this;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return UnresolvableError;
|
|
125
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
var cdnUrl = 'https://cdn.sanity.io';
|
|
131
|
+
/**
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
var fileAssetFilenamePattern = /^([a-zA-Z0-9_]{24,40}|[a-f0-9]{40})+\.[a-z0-9]+$/;
|
|
136
|
+
/**
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
var imageAssetFilenamePattern = /^([a-zA-Z0-9_]{24,40}|[a-f0-9]{40})-\d+x\d+\.[a-z0-9]+$/;
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
var pathPattern = /^(images|files)\/([a-z0-9]+)\/([a-z0-9][-\w]*)\//;
|
|
146
|
+
/**
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
var idPattern = /^(?:image-[a-zA-Z0-9_]+-\d+x\d+-[a-z0-9]+|file-[a-zA-Z0-9_]+-[a-z0-9]+)$/;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Checks whether or not the given source is a Sanity reference
|
|
154
|
+
* (an object containing _ref string key)
|
|
155
|
+
*
|
|
156
|
+
* @param ref - Possible reference
|
|
157
|
+
* @returns Whether or not the passed object is a reference
|
|
158
|
+
*/
|
|
159
|
+
function isReference(ref) {
|
|
160
|
+
return isObject(ref) && typeof ref._ref === 'string';
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Checks whether or not the given source is an asset ID stub
|
|
164
|
+
* (an object containing an `_id` property)
|
|
165
|
+
*
|
|
166
|
+
* @param stub - Possible asset id stub
|
|
167
|
+
* @returns Whether or not the passed object is an object id stub
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
function isAssetIdStub(stub) {
|
|
171
|
+
return isObject(stub) && typeof stub._id === 'string';
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Checks whether or not the given source is an asset path stub
|
|
175
|
+
* (an object containing a `path` property)
|
|
176
|
+
*
|
|
177
|
+
* @param stub - Possible asset path stub
|
|
178
|
+
* @returns Whether or not the passed object is an object path stub
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
function isAssetPathStub(stub) {
|
|
182
|
+
return isObject(stub) && typeof stub.path === 'string';
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Checks whether or not the given source is an asset URL stub
|
|
186
|
+
* (an object containing a `url` property)
|
|
187
|
+
*
|
|
188
|
+
* @param stub - Possible asset url stub
|
|
189
|
+
* @returns Whether or not the passed object is an object url stub
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
function isAssetUrlStub(stub) {
|
|
193
|
+
return isObject(stub) && typeof stub.url === 'string';
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Checks whether or not the given source is an asset object stub
|
|
197
|
+
*
|
|
198
|
+
* @param stub - Possible asset object stub
|
|
199
|
+
* @returns Whether or not the passed object is an object stub
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
function isAssetObjectStub(stub) {
|
|
203
|
+
var item = stub;
|
|
204
|
+
return isObject(item) && item.asset && typeof item.asset === 'object';
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Checks whether or not the passed object is an object (and not `null`)
|
|
208
|
+
*
|
|
209
|
+
* @param obj Item to check whether or not is an object
|
|
210
|
+
* @returns Whether or not `obj` is an object
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
function isObject(obj) {
|
|
215
|
+
return obj !== null && !Array.isArray(obj) && typeof obj === 'object';
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Strips the CDN URL and query params from a URL, eg:
|
|
219
|
+
* `https://cdn.sanity.io/images/project/dataset/filename-200x200.jpg?foo=bar` =>
|
|
220
|
+
* `images/project/dataset/filename-200x200.jpg`
|
|
221
|
+
*
|
|
222
|
+
* @param url - URL to get path name from
|
|
223
|
+
* @returns The path of a CDN URL
|
|
224
|
+
* @throws If URL is not a valid Sanity asset URL
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
function getUrlPath(url) {
|
|
228
|
+
if (pathPattern.test(url)) {
|
|
229
|
+
// Already just a path
|
|
230
|
+
return url;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (!url.startsWith(cdnUrl + "/")) {
|
|
234
|
+
throw new UnresolvableError("Failed to resolve path from URL \"" + url + "\"");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
var qsPos = url.indexOf('?');
|
|
238
|
+
var toIndex = qsPos === -1 ? undefined : qsPos;
|
|
239
|
+
return url.slice(cdnUrl.length + 1, toIndex);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
var exampleImageId = 'image-027401f31c3ac1e6d78c5d539ccd1beff72b9b11-2000x3000-jpg';
|
|
246
|
+
/**
|
|
247
|
+
* Parses a Sanity image asset document ID into individual parts (type, id, extension, width, height)
|
|
248
|
+
*
|
|
249
|
+
* @param documentId - Image asset document ID to parse into named parts
|
|
250
|
+
* @returns Object of named properties
|
|
251
|
+
* @throws If document ID invalid
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
function parseImageAssetId(documentId) {
|
|
255
|
+
var _documentId$split2 = documentId.split('-'),
|
|
256
|
+
assetId = _documentId$split2[1],
|
|
257
|
+
dimensionString = _documentId$split2[2],
|
|
258
|
+
extension = _documentId$split2[3];
|
|
259
|
+
|
|
260
|
+
var _split$map = (dimensionString || '').split('x').map(Number),
|
|
261
|
+
width = _split$map[0],
|
|
262
|
+
height = _split$map[1];
|
|
263
|
+
|
|
264
|
+
if (!assetId || !dimensionString || !extension || !(width > 0) || !(height > 0)) {
|
|
265
|
+
throw new Error("Malformed asset ID '" + documentId + "'. Expected an id like \"" + exampleImageId + "\".");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
type: 'image',
|
|
270
|
+
assetId: assetId,
|
|
271
|
+
width: width,
|
|
272
|
+
height: height,
|
|
273
|
+
extension: extension
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Returns the width, height and aspect ratio of a passed image asset, from any
|
|
279
|
+
* inferrable structure (id, url, path, asset document, image object etc)
|
|
280
|
+
*
|
|
281
|
+
* @param src - Input source (image object, asset, reference, id, url, path)
|
|
282
|
+
* @returns Object with width, height and aspect ratio properties
|
|
283
|
+
*
|
|
284
|
+
* @throws {@link UnresolvableError}
|
|
285
|
+
* Throws if passed image source could not be resolved to an asset ID
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
function getImageDimensions(src) {
|
|
289
|
+
var imageId = getAssetDocumentId(src);
|
|
290
|
+
|
|
291
|
+
var _parseImageAssetId = parseImageAssetId(imageId),
|
|
292
|
+
width = _parseImageAssetId.width,
|
|
293
|
+
height = _parseImageAssetId.height;
|
|
294
|
+
|
|
295
|
+
var aspectRatio = width / height;
|
|
296
|
+
return {
|
|
297
|
+
width: width,
|
|
298
|
+
height: height,
|
|
299
|
+
aspectRatio: aspectRatio
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Tries to resolve the asset document ID from any inferrable structure
|
|
304
|
+
*
|
|
305
|
+
* @param src - Input source (image/file object, asset, reference, id, url, path)
|
|
306
|
+
* @returns The asset document ID
|
|
307
|
+
*
|
|
308
|
+
* @throws {@link UnresolvableError}
|
|
309
|
+
* Throws if passed asset source could not be resolved to an asset document ID
|
|
310
|
+
*/
|
|
311
|
+
|
|
312
|
+
function getAssetDocumentId(src) {
|
|
313
|
+
var source = isAssetObjectStub(src) ? src.asset : src;
|
|
314
|
+
var id = '';
|
|
315
|
+
|
|
316
|
+
if (typeof source === 'string') {
|
|
317
|
+
id = getIdFromString(source);
|
|
318
|
+
} else if (isReference(source)) {
|
|
319
|
+
id = source._ref;
|
|
320
|
+
} else if (isAssetIdStub(source)) {
|
|
321
|
+
id = source._id;
|
|
322
|
+
} else if (isAssetPathStub(source)) {
|
|
323
|
+
id = idFromUrl(cdnUrl + "/" + source.path);
|
|
324
|
+
} else if (isAssetUrlStub(source)) {
|
|
325
|
+
id = idFromUrl(source.url);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
var hasId = id && idPattern.test(id);
|
|
329
|
+
|
|
330
|
+
if (!hasId) {
|
|
331
|
+
throw new UnresolvableError(src);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return id;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Tries to cooerce a string (ID, URL or path) to an image asset ID
|
|
338
|
+
*
|
|
339
|
+
* @param str - Input string (ID, URL or path)
|
|
340
|
+
* @returns string
|
|
341
|
+
*
|
|
342
|
+
*
|
|
343
|
+
* @throws {@link UnresolvableError}
|
|
344
|
+
* Throws if passed image source could not be resolved to an asset ID
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
function getIdFromString(str) {
|
|
348
|
+
if (idPattern.test(str)) {
|
|
349
|
+
// Already an ID
|
|
350
|
+
return str;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (str.indexOf(cdnUrl + "/images") === 0 || str.indexOf(cdnUrl + "/files") === 0) {
|
|
354
|
+
// Full URL
|
|
355
|
+
return idFromUrl(str);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (pathPattern.test(str)) {
|
|
359
|
+
// Path
|
|
360
|
+
return idFromUrl(cdnUrl + "/" + str);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (isFileAssetFilename(str)) {
|
|
364
|
+
// Just a filename (projectId/dataset irrelevant: just need asset ID)
|
|
365
|
+
return idFromUrl(cdnUrl + "/files/a/b/" + str);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (isImageAssetFilename(str)) {
|
|
369
|
+
// Just a filename (projectId/dataset irrelevant: just need asset ID)
|
|
370
|
+
return idFromUrl(cdnUrl + "/images/a/b/" + str);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
throw new UnresolvableError(str);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Converts from a full asset URL to just the asset document ID
|
|
377
|
+
*
|
|
378
|
+
* @param url - A full asset URL to convert
|
|
379
|
+
* @returns string
|
|
380
|
+
*/
|
|
381
|
+
|
|
382
|
+
function idFromUrl(url) {
|
|
383
|
+
var path = getUrlPath(url);
|
|
384
|
+
|
|
385
|
+
var _path$split = path.split('/'),
|
|
386
|
+
type = _path$split[0],
|
|
387
|
+
fileName = _path$split[3];
|
|
388
|
+
|
|
389
|
+
var prefix = type.replace(/s$/, '');
|
|
390
|
+
return prefix + "-" + fileName.replace(/\./g, '-');
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Returns whether or not the passed filename is a valid image asset filename
|
|
394
|
+
*
|
|
395
|
+
* @param filename - Filename to validate
|
|
396
|
+
* @returns Whether or not the filename is an image asset filename
|
|
397
|
+
*/
|
|
398
|
+
|
|
399
|
+
function isImageAssetFilename(filename) {
|
|
400
|
+
return imageAssetFilenamePattern.test(filename);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Returns whether or not the passed filename is a valid file asset filename
|
|
404
|
+
*
|
|
405
|
+
* @param filename - Filename to validate
|
|
406
|
+
* @returns Whether or not the filename is a file asset filename
|
|
407
|
+
*/
|
|
408
|
+
|
|
409
|
+
function isFileAssetFilename(filename) {
|
|
410
|
+
return fileAssetFilenamePattern.test(filename);
|
|
411
|
+
}
|
|
412
|
+
|
|
12
413
|
/* eslint-disable camelcase */
|
|
13
414
|
// Feature query to be used
|
|
14
415
|
// const featureQuery = `*[_type == 'feature' && is_active == true && feature_url == "/"] | order(_updatedAt asc)[0..5]{
|
|
@@ -33,11 +434,18 @@ var Feature = function Feature(props) {
|
|
|
33
434
|
return false;
|
|
34
435
|
};
|
|
35
436
|
|
|
437
|
+
var featureImgDimensions = function featureImgDimensions(image) {
|
|
438
|
+
if (image) {
|
|
439
|
+
var dims = getImageDimensions(image);
|
|
440
|
+
return { width: dims.width, height: dims.height };
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
36
444
|
// image width updated.
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
}
|
|
445
|
+
// let imageWidth = 900
|
|
446
|
+
// if (isMobileOnly) {
|
|
447
|
+
// imageWidth = 225
|
|
448
|
+
// }
|
|
41
449
|
|
|
42
450
|
var renderUrl = function renderUrl(feature_link, feature_title, feature_body) {
|
|
43
451
|
if (checkUrlIsExternal(feature_link)) {
|
|
@@ -97,7 +505,8 @@ var Feature = function Feature(props) {
|
|
|
97
505
|
hide_title_body = feature.hide_title_body,
|
|
98
506
|
feature_img = feature.feature_img,
|
|
99
507
|
feature_alt = feature.feature_alt,
|
|
100
|
-
feature_link = feature.feature_link
|
|
508
|
+
feature_link = feature.feature_link,
|
|
509
|
+
feature_contain = feature.feature_contain;
|
|
101
510
|
|
|
102
511
|
return React__default.createElement(
|
|
103
512
|
Carousel.Item,
|
|
@@ -105,9 +514,11 @@ var Feature = function Feature(props) {
|
|
|
105
514
|
return openLink(feature_link);
|
|
106
515
|
} },
|
|
107
516
|
React__default.createElement('img', {
|
|
108
|
-
style: { maxHeight: '375px',
|
|
517
|
+
style: { maxHeight: '375px', objectFit: feature_contain ? 'contain' : 'cover', cursor: 'pointer' },
|
|
109
518
|
className: 'd-block w-100',
|
|
110
|
-
src: urlFor({ client: client, source: feature_img, imageWidth:
|
|
519
|
+
src: urlFor({ client: client, source: feature_img, imageWidth: featureImgDimensions(feature_img).width }),
|
|
520
|
+
width: featureImgDimensions(feature_img).width,
|
|
521
|
+
height: featureImgDimensions(feature_img).height,
|
|
111
522
|
alt: feature_alt
|
|
112
523
|
}),
|
|
113
524
|
!hide_title_body && React__default.createElement(
|
package/dist/esm/View.js
CHANGED
|
@@ -30,7 +30,6 @@ import { DiscussionEmbed } from 'disqus-react';
|
|
|
30
30
|
import Schema from './Schema.js';
|
|
31
31
|
import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers-0c4b6f40.js';
|
|
32
32
|
import { PixelTrackingArticle } from './PixelTracking.js';
|
|
33
|
-
import './Segment.js';
|
|
34
33
|
import { _ as _Object$keys } from './keys-31dcdb31.js';
|
|
35
34
|
import { I as InfiniteScroll } from './index.es-a6137319.js';
|
|
36
35
|
import { l as lib_3 } from './index-5cc7b406.js';
|
|
@@ -49,6 +48,7 @@ import 'react-share';
|
|
|
49
48
|
import 'react-bootstrap';
|
|
50
49
|
import './index-c7e2ac95.js';
|
|
51
50
|
import './Beam.js';
|
|
51
|
+
import './Segment.js';
|
|
52
52
|
import './brightcove-react-player-loader.es-57a70a56.js';
|
|
53
53
|
import './_object-to-array-b61d5965.js';
|
|
54
54
|
import 'react-bootstrap/Modal';
|
|
@@ -576,9 +576,8 @@ var Recommended = function Recommended(props) {
|
|
|
576
576
|
|
|
577
577
|
case 11:
|
|
578
578
|
_context.next = 13;
|
|
579
|
-
return fetch('/api/getSegmentProfile', {
|
|
580
|
-
method: '
|
|
581
|
-
body: _JSON$stringify({ anonymousId: anonymousId })
|
|
579
|
+
return fetch('/api/getSegmentProfile?anonymousId=' + anonymousId, {
|
|
580
|
+
method: 'GET'
|
|
582
581
|
});
|
|
583
582
|
|
|
584
583
|
case 13:
|
package/dist/esm/getQuery.js
CHANGED
|
@@ -9,7 +9,7 @@ var getQuery = function getQuery(type) {
|
|
|
9
9
|
switch (type) {
|
|
10
10
|
// quiz video series and slideshow
|
|
11
11
|
case 'related':
|
|
12
|
-
return '*[\n _type == "article"\n && defined(title)\n && defined(url)\n && !(_id in path("drafts.**"))\n && is_visible == true\n && defined(published) \n && dateTime(published) <= dateTime(now())\n && passwordLock!=true\n && isHealthcareProfessional != true\n && taxonomyMapping[]._ref in $taxonomy\n && taxonomyMapping[].disableAds != \'true\'\n && contentCategory->.name != \'Poll\'\n && contentCategory->.name != \'Slideshows\'\n && contentCategory->.disableAds != \'true\'\n && ExcludeFromInfiniteScroll !=true\n && url.current != $url\n && !defined(body[].videos)\n && !defined(body[].quizzes)\n && !defined(body[].slides)\n && !defined(body[].articles)\n ' + conditions + '\n ]| order(published desc)[' + (articleCount ? articleCount : '$index') + ']{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n abstract,\n ...,\n passwordLock,\n password,\n "authorDetails": authorMapping[]->{ displayName, firstName, lastName, url, profileImage, biography, showSocialShare },\n body[] {\n ...,\n asset->,\n images[]{\n ...,\n asset->\n },\n content[]{\n ...,\n asset->\n },\n videos[]{\n ...,\n thumbnail{\n _type,\n asset->\n }\n },\n response[]{\n ...,\n asset->\n },\n quizzes[]{\n ...,\n answer[]{\n ...,\n asset->\n },\n question[]{\n ...,\n asset->\n }\n },\n poster {\n _type,\n asset->\n },\n slides[]{\n ...,\n slideshowImage{\n ...,\n asset->\n }\n },\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n }\n },\n \'category\':contentCategory->{\n name,\n disableAds\n },\n \'content_placement\': taxonomyMapping[]-> {\n
|
|
12
|
+
return '*[\n _type == "article"\n && defined(title)\n && defined(url)\n && !(_id in path("drafts.**"))\n && is_visible == true\n && defined(published) \n && dateTime(published) <= dateTime(now())\n && passwordLock!=true\n && isHealthcareProfessional != true\n && taxonomyMapping[]._ref in $taxonomy\n && taxonomyMapping[].disableAds != \'true\'\n && contentCategory->.name != \'Poll\'\n && contentCategory->.name != \'Slideshows\'\n && contentCategory->.disableAds != \'true\'\n && ExcludeFromInfiniteScroll !=true\n && url.current != $url\n && !defined(body[].videos)\n && !defined(body[].quizzes)\n && !defined(body[].slides)\n && !defined(body[].articles)\n ' + conditions + '\n ]| order(published desc)[' + (articleCount ? articleCount : '$index') + ']{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n abstract,\n ...,\n passwordLock,\n password,\n "authorDetails": authorMapping[]->{ displayName, firstName, lastName, url, profileImage, biography, showSocialShare },\n body[] {\n ...,\n asset->,\n images[]{\n ...,\n asset->\n },\n content[]{\n ...,\n asset->\n },\n videos[]{\n ...,\n thumbnail{\n _type,\n asset->\n }\n },\n response[]{\n ...,\n asset->\n },\n quizzes[]{\n ...,\n answer[]{\n ...,\n asset->\n },\n question[]{\n ...,\n asset->\n }\n },\n poster {\n _type,\n asset->\n },\n slides[]{\n ...,\n slideshowImage{\n ...,\n asset->\n }\n },\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n }\n },\n \'category\':contentCategory->{\n name,\n disableAds\n },\n \'content_placement\': taxonomyMapping[]-> {\n ...,\n \'ancestor\': parent->parent->identifier,\n \'parent\': parent->identifier,\n \'name\': name,\n \'path\': identifier,\n showSocialShare,\n pixelTrackingCode->\n },\n documentGroup-> {\n name,\n thumbnail,\n hideThumbnail,\n parent->{...,parent->},\n isShow,\n showSocialShare,\n \'path\': identifier.current,\n adTargetingURL,\n hideSeriesSlider,\n pixelTrackingCode->\n },\n documentGroupMapping[]-> {\n _id,\n name,\n thumbnail,\n parent->{...,parent->},\n isShow,\n showSocialShare,\n \'path\': identifier.current,\n adTargetingURL,\n hideSeriesSlider,\n pixelTrackingCode->\n },\n \'issue\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.issueGroup._ref][0] {\n name,\n \'path\': identifier.current,\n show_download_ris_button,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current,\n show_download_ris_button,\n },\n \'url\' : pdf.asset-> url,\n \'pdf\': pdf.asset->,\n isbn_issn,\n abbreviatedJournal,\n }\n }';
|
|
13
13
|
case 'article':
|
|
14
14
|
return '*[\n _type == "article"\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible != false\n && url.current == $url\n ' + conditions + '\n ][0]{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n abstract,\n ...,\n passwordLock,\n password,\n disableNativeAds,\n issueGroup-> { _id, name, identifier, showIssueNameOnly, showPageNumber, risMapping, parent-> },\n "authorDetails": authorMapping[]->{ displayName, firstName, lastName, url, profileImage, biography, showSocialShare },\n body[] {\n ...,\n asset->,\n images[]{\n ...,\n asset->\n },\n content[]{\n ...,\n asset->\n },\n videos[]{\n ...,\n thumbnail{\n _type,\n asset->\n }\n },\n response[]{\n ...,\n asset->\n },\n quizzes[]{\n ...,\n answer[]{\n ...,\n asset->\n },\n question[]{\n ...,\n asset->\n }\n },\n poster {\n _type,\n asset->\n },\n slides[]{\n ...,\n slideshowImage{\n ...,\n asset->\n }\n },\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n },\n medias[]{\n ...,\n upload_doc {\n _type,\n asset-> \n },\n poster {\n _type,\n asset-> \n }\n },\n articles[]{\n ...,\n thumbnail{\n ...,\n asset-> \n },\n "authorDetails": authorMapping[]->{ displayName, firstName, lastName, url, profileImage, biography, showSocialShare },\n text[]{\n ...,\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n },\n }\n }\n },\n \'content_placement\': taxonomyMapping[]-> {\n ...,\n \'ancestor\': parent->parent->identifier,\n \'parent\': parent->identifier,\n \'name\': name,\n \'path\': identifier,\n showSocialShare,\n pixelTrackingCode->\n },\n documentGroup-> {\n _id,\n name,\n thumbnail,\n hideThumbnail,\n parent->{...,parent->},\n isShow,\n isSeries,\n disableEpisodeNumber,\n excludeRelatedContents,\n showSocialShare,\n \'path\': identifier.current,\n adTargetingURL,\n hideSeriesSlider,\n pixelTrackingCode->\n },\n documentGroupMapping[]-> {\n _id,\n name,\n thumbnail,\n isSeries,\n disableEpisodeNumber,\n parent->{...,parent->},\n isShow,\n showSocialShare,\n excludeRelatedContents,\n \'path\': identifier.current,\n hideSeriesSlider,\n pixelTrackingCode->\n },\n \'category\':contentCategory->{\n name,\n disableAds\n },\n \'issue\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.issueGroup._ref][0] {\n name,\n volume,\n year,\n \'issueNumber\': number,\n \'articleSource\': source,\n \'path\': identifier.current,\n show_download_ris_button,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current,\n show_download_ris_button,\n },\n \'url\' : pdf.asset-> url,\n \'pdf\': pdf.asset->,\n isbn_issn,\n abbreviatedJournal,\n }\n\n }';
|
|
15
15
|
case 'publication':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mjhls/mjh-framework",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1067-featureUpdate",
|
|
4
4
|
"description": "Foundation Framework",
|
|
5
5
|
"author": "mjh-framework",
|
|
6
6
|
"license": "MIT",
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"dist"
|
|
93
93
|
],
|
|
94
94
|
"dependencies": {
|
|
95
|
+
"@sanity/asset-utils": "^1.2.3",
|
|
95
96
|
"@supabase/supabase-js": "^1.29.4",
|
|
96
97
|
"babel-polyfill": "^6.26.0",
|
|
97
98
|
"cookie": "^0.4.1",
|