@mjhls/mjh-framework 1.0.665-beta.2 → 1.0.665-beta.3

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/View.js CHANGED
@@ -59,7 +59,7 @@ var keys = require('./keys-a586b7a0.js');
59
59
  require('react-bootstrap/Dropdown');
60
60
  var getSeriesDetail = require('./getSeriesDetail.js');
61
61
  require('./index-bd6c9f56.js');
62
- var getRelatedArticle = require('./getRelatedArticle-c944847e.js');
62
+ var getRelatedArticle = require('./getRelatedArticle.js');
63
63
  var getQuery = require('./getQuery.js');
64
64
  var getTargeting = require('./getTargeting-9af0ef69.js');
65
65
  var getKeywords = require('./getKeywords.js');
@@ -1020,13 +1020,12 @@ var _this = undefined;
1020
1020
 
1021
1021
  var getRelatedContents = function () {
1022
1022
  var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
1023
- var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1024
1023
  var client = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1025
1024
  var article = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1026
1025
  var prevUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';
1027
1026
  var articleCount = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
1028
1027
 
1029
- var _article$url, url, content_placement, documentGroupMapping, issueGroup, params, conditions, taxonomy, documentGroup, cookies, prevSlugs, relatedContents, relatedContentQuery;
1028
+ var _article$url, url, content_placement, documentGroupMapping, issueGroup, params, conditions, taxonomy, documentGroup, relatedContents, relatedContentQuery;
1030
1029
 
1031
1030
  return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
1032
1031
  while (1) {
@@ -1038,8 +1037,7 @@ var getRelatedContents = function () {
1038
1037
  } : _article$url;
1039
1038
  url = _article$url.current, content_placement = article.content_placement, documentGroupMapping = article.documentGroupMapping, issueGroup = article.issueGroup;
1040
1039
  params = {
1041
- url: url,
1042
- index: articleCount
1040
+ url: url
1043
1041
  };
1044
1042
  conditions = '';
1045
1043
 
@@ -1061,15 +1059,20 @@ var getRelatedContents = function () {
1061
1059
  }
1062
1060
  if (prev_url_to_check.endsWith(path) && _id) taxonomy.push(_id);
1063
1061
  });
1064
- if (taxonomy.length === 0) content_placement.filter(function (_ref3) {
1065
- var identifier = _ref3.identifier;
1066
- return identifier !== 'news';
1067
- }).forEach(function (_ref4) {
1068
- var _id = _ref4._id;
1069
-
1070
- if (_id) taxonomy.push(_id);
1071
- });
1072
- params = _extends$1._extends({}, params, { taxonomy: taxonomy });
1062
+ if (taxonomy.length === 0) {
1063
+ content_placement.filter(function (_ref3) {
1064
+ var identifier = _ref3.identifier;
1065
+ return identifier !== 'news';
1066
+ }).forEach(function (_ref4) {
1067
+ var _id = _ref4._id;
1068
+
1069
+ if (_id) taxonomy.push(_id);
1070
+ });
1071
+ }
1072
+ if (taxonomy.length > 0) {
1073
+ params = _extends$1._extends({}, params, { taxonomy: taxonomy });
1074
+ conditions = '&& taxonomyMapping[]._ref in $taxonomy';
1075
+ }
1073
1076
  }
1074
1077
 
1075
1078
  if (documentGroupMapping && documentGroupMapping.length > 0) {
@@ -1080,48 +1083,56 @@ var getRelatedContents = function () {
1080
1083
 
1081
1084
  if (_id) documentGroup.push(_id);
1082
1085
  });
1083
- params = _extends$1._extends({}, params, { documentGroup: documentGroup });
1084
- conditions = conditions.concat('&& documentGroupMapping[]._ref in $documentGroup ');
1085
- }
1086
-
1087
- if (issueGroup) {
1088
- params = _extends$1._extends({}, params, { issueAssociation: issueGroup._ref });
1089
- conditions = conditions.concat('&& issueGroup._ref == $issueAssociation ');
1086
+ if (params.taxonomy && documentGroup.length > 0) {
1087
+ params = _extends$1._extends({}, params, { documentGroup: documentGroup });
1088
+ conditions = '&& (taxonomyMapping[]._ref in $taxonomy || documentGroupMapping[]._ref in $documentGroup)';
1089
+ }
1090
1090
  }
1091
1091
 
1092
- if (ctx && url) {
1093
- cookies = getRelatedArticle.dist_3(ctx);
1094
- prevSlugs = cookies['prevSlugs'];
1095
-
1096
- if (!!prevSlugs) {
1097
- getRelatedArticle.dist_2(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"', {});
1098
- conditions = '&& !(url.current in [' + prevSlugs + '])';
1099
- } else getRelatedArticle.dist_2(ctx, 'prevSlugs', '"' + url + '"', {});
1092
+ if (issueGroup && issueGroup._ref) {
1093
+ if (params.taxonomy && params.documentGroup) {
1094
+ params = _extends$1._extends({}, params, { issueAssociation: issueGroup._ref });
1095
+ conditions = '&& (taxonomyMapping[]._ref in $taxonomy || documentGroupMapping[]._ref in $documentGroup || issueGroup._ref == $issueAssociation )';
1096
+ } else if (params.taxonomy) {
1097
+ params = _extends$1._extends({}, params, { issueAssociation: issueGroup._ref });
1098
+ conditions = '&& (taxonomyMapping[]._ref in $taxonomy || issueGroup._ref == $issueAssociation )';
1099
+ }
1100
1100
  }
1101
1101
 
1102
1102
  relatedContents = [];
1103
1103
 
1104
1104
  if (!(params.taxonomy && params.taxonomy.length > 0)) {
1105
- _context.next = 15;
1105
+ _context.next = 21;
1106
1106
  break;
1107
1107
  }
1108
1108
 
1109
- relatedContentQuery = getQuery('related', conditions, '', articleCount);
1109
+ relatedContentQuery = '*[\n _type == "article"\n && defined(title)\n && defined(url)\n && !(_id in path("drafts.**"))\n && taxonomyMapping[].disableAds != \'true\'\n && contentCategory.name != \'Poll\'\n && contentCategory.name != \'Slideshows\'\n \t&& contentCategory.disableAds != \'true\'\n && ExcludeFromInfiniteScroll !=true\n && url.current != $url\n && !defined(body[].videos)\n && published <= \'' + new Date().toISOString() + '\'\n ' + conditions + '\n\n // && is_visible == true\n // && passwordLock!=true\n\n\n ]| order(published desc)[' + articleCount + ']\n {\n title,\n url,\n thumbnail\n }';
1110
+ _context.prev = 11;
1110
1111
  _context.next = 14;
1111
1112
  return client.fetch(relatedContentQuery, params);
1112
1113
 
1113
1114
  case 14:
1114
1115
  relatedContents = _context.sent;
1115
1116
 
1116
- case 15:
1117
+ debugger;
1118
+ _context.next = 21;
1119
+ break;
1120
+
1121
+ case 18:
1122
+ _context.prev = 18;
1123
+ _context.t0 = _context['catch'](11);
1124
+
1125
+ console.error(_context.t0);
1126
+
1127
+ case 21:
1117
1128
  return _context.abrupt('return', relatedContents);
1118
1129
 
1119
- case 16:
1130
+ case 22:
1120
1131
  case 'end':
1121
1132
  return _context.stop();
1122
1133
  }
1123
1134
  }
1124
- }, _callee, _this);
1135
+ }, _callee, _this, [[11, 18]]);
1125
1136
  }));
1126
1137
 
1127
1138
  return function getRelatedContents() {
@@ -1264,7 +1275,7 @@ var ArticleQueue = function ArticleQueue(props) {
1264
1275
  startingIndex = queueData.length + 1;
1265
1276
  endingIndex = startingIndex + 2;
1266
1277
  _context.next = 5;
1267
- return getRelatedArticle.getRelatedArticle(null, props.client, article, prevUrl, startingIndex + '..' + endingIndex);
1278
+ return getRelatedArticle(null, props.client, article, prevUrl, startingIndex + '..' + endingIndex);
1268
1279
 
1269
1280
  case 5:
1270
1281
  article.relatedArticle = _context.sent;
@@ -1649,7 +1660,7 @@ View.returnGetInitialProps = function () {
1649
1660
  }
1650
1661
 
1651
1662
  _context.next = 17;
1652
- return getRelatedArticle.getRelatedArticle(context, client, article, prevUrl, '0..2');
1663
+ return getRelatedArticle(context, client, article, prevUrl, '0..2');
1653
1664
 
1654
1665
  case 17:
1655
1666
  article.relatedArticle = _context.sent;
@@ -1,18 +1,452 @@
1
1
  'use strict';
2
2
 
3
- require('./_commonjsHelpers-06173234.js');
3
+ var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
4
4
  require('./_to-object-329a650b.js');
5
5
  require('./es6.string.iterator-cc0bbaa4.js');
6
6
  require('./_library-dd23b178.js');
7
7
  require('./_iter-detect-60b2f026.js');
8
8
  require('./core.get-iterator-method-f62321d4.js');
9
9
  require('./web.dom.iterable-a0e279c1.js');
10
- require('./asyncToGenerator-533d476a.js');
10
+ var asyncToGenerator = require('./asyncToGenerator-533d476a.js');
11
11
  require('./_set-species-f92c67c5.js');
12
- require('./index-bd6c9f56.js');
13
- var getRelatedArticle = require('./getRelatedArticle-c944847e.js');
14
- require('./getQuery.js');
12
+ var index$4 = require('./index-bd6c9f56.js');
13
+ var getQuery = require('./getQuery.js');
15
14
 
15
+ var defaultParseOptions = {
16
+ decodeValues: true,
17
+ map: false,
18
+ silent: false,
19
+ };
16
20
 
21
+ function isNonEmptyString(str) {
22
+ return typeof str === "string" && !!str.trim();
23
+ }
17
24
 
18
- module.exports = getRelatedArticle.getRelatedArticle;
25
+ function parseString(setCookieValue, options) {
26
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
27
+ var nameValue = parts.shift().split("=");
28
+ var name = nameValue.shift();
29
+ var value = nameValue.join("="); // everything after the first =, joined by a "=" if there was more than one part
30
+
31
+ options = options
32
+ ? Object.assign({}, defaultParseOptions, options)
33
+ : defaultParseOptions;
34
+
35
+ var cookie = {
36
+ name: name, // grab everything before the first =
37
+ value: options.decodeValues ? decodeURIComponent(value) : value, // decode cookie value
38
+ };
39
+
40
+ parts.forEach(function (part) {
41
+ var sides = part.split("=");
42
+ var key = sides.shift().trimLeft().toLowerCase();
43
+ var value = sides.join("=");
44
+ if (key === "expires") {
45
+ cookie.expires = new Date(value);
46
+ } else if (key === "max-age") {
47
+ cookie.maxAge = parseInt(value, 10);
48
+ } else if (key === "secure") {
49
+ cookie.secure = true;
50
+ } else if (key === "httponly") {
51
+ cookie.httpOnly = true;
52
+ } else if (key === "samesite") {
53
+ cookie.sameSite = value;
54
+ } else {
55
+ cookie[key] = value;
56
+ }
57
+ });
58
+
59
+ return cookie;
60
+ }
61
+
62
+ function parse(input, options) {
63
+ options = options
64
+ ? Object.assign({}, defaultParseOptions, options)
65
+ : defaultParseOptions;
66
+
67
+ if (!input) {
68
+ if (!options.map) {
69
+ return [];
70
+ } else {
71
+ return {};
72
+ }
73
+ }
74
+
75
+ if (input.headers && input.headers["set-cookie"]) {
76
+ // fast-path for node.js (which automatically normalizes header names to lower-case
77
+ input = input.headers["set-cookie"];
78
+ } else if (input.headers) {
79
+ // slow-path for other environments - see #25
80
+ var sch =
81
+ input.headers[
82
+ Object.keys(input.headers).find(function (key) {
83
+ return key.toLowerCase() === "set-cookie";
84
+ })
85
+ ];
86
+ // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
87
+ if (!sch && input.headers.cookie && !options.silent) {
88
+ console.warn(
89
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
90
+ );
91
+ }
92
+ input = sch;
93
+ }
94
+ if (!Array.isArray(input)) {
95
+ input = [input];
96
+ }
97
+
98
+ options = options
99
+ ? Object.assign({}, defaultParseOptions, options)
100
+ : defaultParseOptions;
101
+
102
+ if (!options.map) {
103
+ return input.filter(isNonEmptyString).map(function (str) {
104
+ return parseString(str, options);
105
+ });
106
+ } else {
107
+ var cookies = {};
108
+ return input.filter(isNonEmptyString).reduce(function (cookies, str) {
109
+ var cookie = parseString(str, options);
110
+ cookies[cookie.name] = cookie;
111
+ return cookies;
112
+ }, cookies);
113
+ }
114
+ }
115
+
116
+ /*
117
+ Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
118
+ that are within a single set-cookie field-value, such as in the Expires portion.
119
+
120
+ This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
121
+ Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
122
+ React Native's fetch does this for *every* header, including set-cookie.
123
+
124
+ Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
125
+ Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
126
+ */
127
+ function splitCookiesString(cookiesString) {
128
+ if (Array.isArray(cookiesString)) {
129
+ return cookiesString;
130
+ }
131
+ if (typeof cookiesString !== "string") {
132
+ return [];
133
+ }
134
+
135
+ var cookiesStrings = [];
136
+ var pos = 0;
137
+ var start;
138
+ var ch;
139
+ var lastComma;
140
+ var nextStart;
141
+ var cookiesSeparatorFound;
142
+
143
+ function skipWhitespace() {
144
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
145
+ pos += 1;
146
+ }
147
+ return pos < cookiesString.length;
148
+ }
149
+
150
+ function notSpecialChar() {
151
+ ch = cookiesString.charAt(pos);
152
+
153
+ return ch !== "=" && ch !== ";" && ch !== ",";
154
+ }
155
+
156
+ while (pos < cookiesString.length) {
157
+ start = pos;
158
+ cookiesSeparatorFound = false;
159
+
160
+ while (skipWhitespace()) {
161
+ ch = cookiesString.charAt(pos);
162
+ if (ch === ",") {
163
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
164
+ lastComma = pos;
165
+ pos += 1;
166
+
167
+ skipWhitespace();
168
+ nextStart = pos;
169
+
170
+ while (pos < cookiesString.length && notSpecialChar()) {
171
+ pos += 1;
172
+ }
173
+
174
+ // currently special character
175
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
176
+ // we found cookies separator
177
+ cookiesSeparatorFound = true;
178
+ // pos is inside the next cookie, so back up and return it.
179
+ pos = nextStart;
180
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
181
+ start = pos;
182
+ } else {
183
+ // in param ',' or param separator ';',
184
+ // we continue from that comma
185
+ pos = lastComma + 1;
186
+ }
187
+ } else {
188
+ pos += 1;
189
+ }
190
+ }
191
+
192
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
193
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
194
+ }
195
+ }
196
+
197
+ return cookiesStrings;
198
+ }
199
+
200
+ var setCookie = parse;
201
+ var parse_1 = parse;
202
+ var parseString_1 = parseString;
203
+ var splitCookiesString_1 = splitCookiesString;
204
+ setCookie.parse = parse_1;
205
+ setCookie.parseString = parseString_1;
206
+ setCookie.splitCookiesString = splitCookiesString_1;
207
+
208
+ var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
209
+ var __assign = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__assign) || function () {
210
+ __assign = Object.assign || function(t) {
211
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
212
+ s = arguments[i];
213
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
214
+ t[p] = s[p];
215
+ }
216
+ return t;
217
+ };
218
+ return __assign.apply(this, arguments);
219
+ };
220
+ Object.defineProperty(exports, "__esModule", { value: true });
221
+ exports.destroyCookie = exports.setCookie = exports.parseCookies = void 0;
222
+
223
+
224
+ var isBrowser = function () { return typeof window !== 'undefined'; };
225
+ function hasSameProperties(a, b) {
226
+ var aProps = Object.getOwnPropertyNames(a);
227
+ var bProps = Object.getOwnPropertyNames(b);
228
+ if (aProps.length !== bProps.length) {
229
+ return false;
230
+ }
231
+ for (var i = 0; i < aProps.length; i++) {
232
+ var propName = aProps[i];
233
+ if (a[propName] !== b[propName]) {
234
+ return false;
235
+ }
236
+ }
237
+ return true;
238
+ }
239
+ /**
240
+ * Compare the cookie and return true if the cookies has equivalent
241
+ * options and the cookies would be overwritten in the browser storage.
242
+ *
243
+ * @param a first Cookie for comparison
244
+ * @param b second Cookie for comparison
245
+ */
246
+ function areCookiesEqual(a, b) {
247
+ var sameSiteSame = a.sameSite === b.sameSite;
248
+ if (typeof a.sameSite === 'string' && typeof b.sameSite === 'string') {
249
+ sameSiteSame = a.sameSite.toLowerCase() === b.sameSite.toLowerCase();
250
+ }
251
+ return (hasSameProperties(__assign(__assign({}, a), { sameSite: undefined }), __assign(__assign({}, b), { sameSite: undefined })) && sameSiteSame);
252
+ }
253
+ /**
254
+ * Create an instance of the Cookie interface
255
+ *
256
+ * @param name name of the Cookie
257
+ * @param value value of the Cookie
258
+ * @param options Cookie options
259
+ */
260
+ function createCookie(name, value, options) {
261
+ var sameSite = options.sameSite;
262
+ if (sameSite === true) {
263
+ sameSite = 'strict';
264
+ }
265
+ if (sameSite === undefined || sameSite === false) {
266
+ sameSite = 'lax';
267
+ }
268
+ var cookieToSet = __assign(__assign({}, options), { sameSite: sameSite });
269
+ delete cookieToSet.encode;
270
+ return __assign({ name: name, value: value }, cookieToSet);
271
+ }
272
+ /**
273
+ *
274
+ * Parses cookies.
275
+ *
276
+ * @param ctx
277
+ * @param options
278
+ */
279
+ function parseCookies(ctx, options) {
280
+ if (ctx && ctx.req && ctx.req.headers && ctx.req.headers.cookie) {
281
+ return index$4.cookie.parse(ctx.req.headers.cookie, options);
282
+ }
283
+ if (isBrowser()) {
284
+ return index$4.cookie.parse(document.cookie, options);
285
+ }
286
+ return {};
287
+ }
288
+ exports.parseCookies = parseCookies;
289
+ /**
290
+ *
291
+ * Sets a cookie.
292
+ *
293
+ * @param ctx
294
+ * @param name
295
+ * @param value
296
+ * @param options
297
+ */
298
+ function setCookie$1(ctx, name, value, options) {
299
+ if (ctx && ctx.res && ctx.res.getHeader && ctx.res.setHeader) {
300
+ var cookies = ctx.res.getHeader('Set-Cookie') || [];
301
+ if (typeof cookies === 'string')
302
+ cookies = [cookies];
303
+ if (typeof cookies === 'number')
304
+ cookies = [];
305
+ var parsedCookies = setCookie.parse(cookies);
306
+ var cookiesToSet_1 = [];
307
+ parsedCookies.forEach(function (parsedCookie) {
308
+ if (!areCookiesEqual(parsedCookie, createCookie(name, value, options))) {
309
+ cookiesToSet_1.push(index$4.cookie.serialize(parsedCookie.name, parsedCookie.value, __assign({}, parsedCookie)));
310
+ }
311
+ });
312
+ cookiesToSet_1.push(index$4.cookie.serialize(name, value, options));
313
+ if (!ctx.res.finished) {
314
+ ctx.res.setHeader('Set-Cookie', cookiesToSet_1);
315
+ }
316
+ }
317
+ if (isBrowser()) {
318
+ if (options && options.httpOnly) {
319
+ throw new Error('Can not set a httpOnly cookie in the browser.');
320
+ }
321
+ document.cookie = index$4.cookie.serialize(name, value, options);
322
+ }
323
+ return {};
324
+ }
325
+ exports.setCookie = setCookie$1;
326
+ /**
327
+ *
328
+ * Destroys a cookie with a particular name.
329
+ *
330
+ * @param ctx
331
+ * @param name
332
+ * @param options
333
+ */
334
+ function destroyCookie(ctx, name, options) {
335
+ var opts = __assign(__assign({}, (options || {})), { maxAge: -1 });
336
+ if (ctx && ctx.res && ctx.res.setHeader && ctx.res.getHeader) {
337
+ var cookies = ctx.res.getHeader('Set-Cookie') || [];
338
+ if (typeof cookies === 'string')
339
+ cookies = [cookies];
340
+ if (typeof cookies === 'number')
341
+ cookies = [];
342
+ cookies.push(index$4.cookie.serialize(name, '', opts));
343
+ ctx.res.setHeader('Set-Cookie', cookies);
344
+ }
345
+ if (isBrowser()) {
346
+ document.cookie = index$4.cookie.serialize(name, '', opts);
347
+ }
348
+ return {};
349
+ }
350
+ exports.destroyCookie = destroyCookie;
351
+ exports.default = {
352
+ set: setCookie$1,
353
+ get: parseCookies,
354
+ destroy: destroyCookie,
355
+ };
356
+
357
+ });
358
+
359
+ _commonjsHelpers.unwrapExports(dist);
360
+ var dist_1 = dist.destroyCookie;
361
+ var dist_2 = dist.setCookie;
362
+ var dist_3 = dist.parseCookies;
363
+
364
+ var _this = undefined;
365
+
366
+ var getRelatedArticle = function () {
367
+ var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
368
+ var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
369
+ var client = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
370
+ var article = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
371
+ var prevUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';
372
+ var articleCount = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
373
+
374
+ var taxonomyMapping, _article$url, url, content_placement, taxonomy, params, conditions, cookies, prevSlugs, relatedArticleQuery, relatedArticle;
375
+
376
+ return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
377
+ while (1) {
378
+ switch (_context.prev = _context.next) {
379
+ case 0:
380
+ taxonomyMapping = article.taxonomyMapping, _article$url = article.url;
381
+ _article$url = _article$url === undefined ? {
382
+ current: null
383
+ } : _article$url;
384
+ url = _article$url.current, content_placement = article.content_placement;
385
+ taxonomy = [];
386
+ //404 articles were throwing server error
387
+
388
+ if (content_placement) {
389
+ content_placement.forEach(function (_ref3) {
390
+ var path = _ref3.path,
391
+ _id = _ref3._id;
392
+
393
+ if (!_id || typeof _id == 'undefined') {
394
+ return null;
395
+ }
396
+ var prev_url_to_check = prevUrl;
397
+ if (prev_url_to_check.includes('?')) {
398
+ prev_url_to_check = prev_url_to_check.split('?')[0];
399
+ }
400
+ if (prev_url_to_check.endsWith(path) && _id) taxonomy.push(_id);
401
+ });
402
+ }
403
+
404
+ //404 articles were throwing server error
405
+ if (taxonomy.length === 0 && taxonomyMapping) {
406
+ taxonomyMapping.forEach(function (_ref4) {
407
+ var _ref = _ref4._ref;
408
+
409
+ if (_ref) {
410
+ taxonomy.push(_ref);
411
+ }
412
+ });
413
+ }
414
+
415
+ params = {
416
+ url: url,
417
+ taxonomy: taxonomy,
418
+ index: articleCount
419
+ };
420
+ conditions = '';
421
+
422
+ if (ctx && url) {
423
+ cookies = dist_3(ctx);
424
+ prevSlugs = cookies['prevSlugs'];
425
+
426
+ if (!!prevSlugs) {
427
+ dist_2(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"', {});
428
+ conditions = '&& !(url.current in [' + prevSlugs + '])';
429
+ } else dist_2(ctx, 'prevSlugs', '"' + url + '"', {});
430
+ }
431
+ relatedArticleQuery = getQuery('related', conditions, '', articleCount);
432
+ _context.next = 12;
433
+ return client.fetch(relatedArticleQuery, params);
434
+
435
+ case 12:
436
+ relatedArticle = _context.sent;
437
+ return _context.abrupt('return', relatedArticle);
438
+
439
+ case 14:
440
+ case 'end':
441
+ return _context.stop();
442
+ }
443
+ }
444
+ }, _callee, _this);
445
+ }));
446
+
447
+ return function getRelatedArticle() {
448
+ return _ref2.apply(this, arguments);
449
+ };
450
+ }();
451
+
452
+ module.exports = getRelatedArticle;
package/dist/cjs/index.js CHANGED
@@ -158,7 +158,7 @@ var KMTracker = require('./KMTracker.js');
158
158
  var getSeriesDetail = require('./getSeriesDetail.js');
159
159
  var SetCookie = require('./SetCookie.js');
160
160
  require('./index-bd6c9f56.js');
161
- var getRelatedArticle = require('./getRelatedArticle-c944847e.js');
161
+ var getRelatedArticle = require('./getRelatedArticle.js');
162
162
  var getQuery = require('./getQuery.js');
163
163
  var Auth = require('./Auth.js');
164
164
  require('swr');
@@ -248,7 +248,7 @@ exports.ConferenceArticleCard = ConferenceArticleCard;
248
248
  exports.KMTracker = KMTracker;
249
249
  exports.getSeriesDetail = getSeriesDetail;
250
250
  exports.SetCookie = SetCookie;
251
- exports.getRelatedArticle = getRelatedArticle.getRelatedArticle;
251
+ exports.getRelatedArticle = getRelatedArticle;
252
252
  exports.getQuery = getQuery;
253
253
  exports.Auth = Auth.default;
254
254
  exports.getTargeting = getTargeting.getTargeting;