@mjhls/mjh-framework 1.0.694-beta.0 → 1.0.694-beta.1

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.
Files changed (46) hide show
  1. package/dist/cjs/View.js +175 -136
  2. package/dist/cjs/getQuery.js +2 -2
  3. package/dist/cjs/getRelatedArticle.js +29 -57
  4. package/dist/cjs/index.js +82 -5
  5. package/dist/esm/AD300x250.js +1 -1
  6. package/dist/esm/AD300x250x600.js +1 -1
  7. package/dist/esm/AD728x90.js +1 -1
  8. package/dist/esm/ADFloatingFooter.js +1 -1
  9. package/dist/esm/ADGutter.js +1 -1
  10. package/dist/esm/ADSkyscraper.js +1 -1
  11. package/dist/esm/ADSponsoredResources.js +1 -1
  12. package/dist/esm/ADWebcast.js +1 -1
  13. package/dist/esm/ADWelcome.js +1 -1
  14. package/dist/esm/AdSlot.js +1 -1
  15. package/dist/esm/Auth.js +1 -1
  16. package/dist/esm/Beam.js +1 -1
  17. package/dist/esm/CMEDeck.js +1 -1
  18. package/dist/esm/Column2.js +1 -1
  19. package/dist/esm/Column3.js +1 -1
  20. package/dist/esm/DeckContent.js +2 -2
  21. package/dist/esm/ExternalResources.js +2 -2
  22. package/dist/esm/GridContent.js +3 -3
  23. package/dist/esm/HamMagazine.js +1 -1
  24. package/dist/esm/IssueLanding.js +3 -3
  25. package/dist/esm/LeftNav.js +1 -1
  26. package/dist/esm/MasterDeck.js +3 -3
  27. package/dist/esm/NavDvm.js +1 -1
  28. package/dist/esm/NavMagazine.js +1 -1
  29. package/dist/esm/NavNative.js +1 -1
  30. package/dist/esm/NavNormal.js +1 -1
  31. package/dist/esm/PartnerDetailListing.js +4 -4
  32. package/dist/esm/QueueDeckExpanded.js +3 -3
  33. package/dist/esm/Segment.js +1 -1
  34. package/dist/esm/SideFooter.js +1 -1
  35. package/dist/esm/TemplateNormal.js +1 -1
  36. package/dist/esm/VideoSeriesFilter.js +1 -1
  37. package/dist/esm/View.js +177 -138
  38. package/dist/esm/{asyncToGenerator-7c654f36.js → asyncToGenerator-d0f08f8d.js} +1 -1
  39. package/dist/esm/getQuery.js +2 -2
  40. package/dist/esm/getRelatedArticle.js +30 -58
  41. package/dist/esm/getSerializers.js +2 -2
  42. package/dist/esm/index.js +86 -8
  43. package/package.json +1 -1
  44. /package/dist/esm/{ADInfeed-eae71d07.js → ADInfeed-d46be909.js} +0 -0
  45. /package/dist/esm/{ADlgInfeed-c619fe64.js → ADlgInfeed-5d1bce95.js} +0 -0
  46. /package/dist/esm/{index-c376cd8e.js → index-aad92b92.js} +0 -0
package/dist/cjs/View.js CHANGED
@@ -48,6 +48,7 @@ require('react-bootstrap');
48
48
  require('./iconBase-68959171.js');
49
49
  require('./index.esm-90433435.js');
50
50
  var Button = _interopDefault(require('react-bootstrap/Button'));
51
+ var defineProperty$1 = require('./defineProperty-55548b25.js');
51
52
  var Form = _interopDefault(require('react-bootstrap/Form'));
52
53
  var getSerializers = require('./index-a5919bab.js');
53
54
  require('./util-f2c1b65b.js');
@@ -253,7 +254,7 @@ var ISI = function ISI(props) {
253
254
  );
254
255
  };
255
256
 
256
- var css = ".RelatedArticles-module_mediaContainer__10h9k {\r\n display: flex;\r\n flex-direction: row;\r\n flex-wrap: nowrap;\r\n margin: 0 -1rem;\r\n}\r\n.RelatedArticles-module_mediaCard__3wQbn {\r\n margin: 0 1rem 1rem;\r\n width: calc(33% - 1rem);\r\n display: column;\r\n flex-direction: row;\r\n margin-bottom: 0.75rem;\r\n padding-bottom: 0.75rem;\r\n border-bottom: none;\r\n}\r\n.RelatedArticles-module_mediaCard__3wQbn:last-child {\r\n border-bottom: none;\r\n}\r\n.RelatedArticles-module_cardTitle__3P-Ib {\r\n font-weight: bold;\r\n color: #252525;\r\n margin-bottom: 0.25rem;\r\n font-size: 15px;\r\n}\r\n.RelatedArticles-module_authorListing__1EFg4 span.RelatedArticles-module_text-muted__3b0zX {\r\n color: #000;\r\n font-weight: bold;\r\n}\r\n.RelatedArticles-module_cardDate__1wOR5 {\r\n color: var(--dark);\r\n display: block;\r\n background: #fff !important;\r\n margin-bottom: 0;\r\n}\r\n.RelatedArticles-module_imgWrapper__5Jx_4 {\r\n display: block;\r\n text-align: center;\r\n margin-bottom: 0.5rem;\r\n}\r\n.RelatedArticles-module_imgWrapper__5Jx_4 img {\r\n height: 135px;\r\n width: 100%;\r\n object-fit: cover;\r\n object-position: center;\r\n}\r\n@media screen and (max-width: 1064px) {\r\n}\r\n@media screen and (max-width: 968px) {\r\n .RelatedArticles-module_mediaContainer__10h9k {\r\n flex-wrap: wrap;\r\n }\r\n .RelatedArticles-module_imgWrapper__5Jx_4 {\r\n display: none;\r\n }\r\n .RelatedArticles-module_mediaCard__3wQbn {\r\n width: 100%;\r\n margin-bottom: 0.5rem;\r\n padding: 0;\r\n }\r\n .RelatedArticles-module_cardTitle__3P-Ib {\r\n font-size: 0.75rem;\r\n margin-bottom: 0;\r\n }\r\n}\r\n";
257
+ var css = ".RelatedArticles-module_mediaContainer__10h9k {\r\n display: flex;\r\n flex-direction: row;\r\n flex-wrap: nowrap;\r\n margin: 0 -1rem;\r\n}\r\n.RelatedArticles-module_mediaCard__3wQbn {\r\n margin: 0 1rem 1rem;\r\n width: calc(33% - 1rem);\r\n display: column;\r\n flex-direction: row;\r\n margin-bottom: 0.75rem;\r\n padding-bottom: 0.75rem;\r\n border-bottom: none;\r\n}\r\n.RelatedArticles-module_mediaCard__3wQbn:last-child {\r\n border-bottom: none;\r\n}\r\n.RelatedArticles-module_cardTitle__3P-Ib {\r\n font-weight: bold;\r\n color: #252525;\r\n margin-bottom: 0.25rem;\r\n font-size: 15px;\r\n}\r\n.RelatedArticles-module_authorListing__1EFg4 span.RelatedArticles-module_text-muted__3b0zX {\r\n color: #000;\r\n font-weight: bold;\r\n}\r\n.RelatedArticles-module_cardDate__1wOR5 {\r\n color: var(--dark);\r\n display: block;\r\n background: #fff !important;\r\n margin-bottom: 0;\r\n}\r\n.RelatedArticles-module_imgWrapper__5Jx_4 {\r\n display: block;\r\n text-align: center;\r\n margin-bottom: 0.5rem;\r\n}\r\n.RelatedArticles-module_imgWrapper__5Jx_4 img {\r\n height: 135px;\r\n width: 100%;\r\n object-fit: cover;\r\n object-position: center;\r\n}\r\n@media screen and (max-width: 1064px) {\r\n}\r\n@media screen and (max-width: 968px) {\r\n .RelatedArticles-module_mediaContainer__10h9k {\r\n flex-wrap: wrap;\r\n }\r\n .RelatedArticles-module_mediaCard__3wQbn {\r\n width: 100%;\r\n }\r\n .RelatedArticles-module_imgWrapper__5Jx_4 img {\r\n width: 100%;\r\n height: auto;\r\n\r\n max-height: 175px;\r\n object-fit: contain;\r\n margin-bottom: 1rem;\r\n }\r\n}\r\n";
257
258
  var styles = { "mediaContainer": "RelatedArticles-module_mediaContainer__10h9k", "mediaCard": "RelatedArticles-module_mediaCard__3wQbn", "cardTitle": "RelatedArticles-module_cardTitle__3P-Ib", "authorListing": "RelatedArticles-module_authorListing__1EFg4", "text-muted": "RelatedArticles-module_text-muted__3b0zX", "cardDate": "RelatedArticles-module_cardDate__1wOR5", "imgWrapper": "RelatedArticles-module_imgWrapper__5Jx_4" };
258
259
  styleInject_es.styleInject(css);
259
260
 
@@ -489,73 +490,65 @@ var Article = function Article(props) {
489
490
  };
490
491
 
491
492
  var RelevantTopics = function RelevantTopics() {
492
- if (content_placement && content_placement.length > 0 || documentGroupMapping && documentGroupMapping.length > 0) {
493
- var relatedLinks = [];
494
- if (documentGroupMapping && documentGroupMapping.length > 0) {
495
- documentGroupMapping.forEach(function (documentGroup) {
496
- if (documentGroup.parent) {
497
- relatedLinks = [].concat(toConsumableArray._toConsumableArray(relatedLinks), [{ label: documentGroup.name, href: cpModificationRequired ? '/' + documentGroup.parent.identifier.current + '/' + documentGroup.path : '/' + documentGroup.path }]);
493
+ if (content_placement && content_placement.length > 0 || documentGroupMapping) {
494
+ return React__default.createElement(
495
+ 'div',
496
+ { style: { color: '#262626' } },
497
+ React__default.createElement(
498
+ 'p',
499
+ { className: 'mb-0' },
500
+ React__default.createElement(
501
+ 'b',
502
+ null,
503
+ 'Related Content:'
504
+ )
505
+ ),
506
+ documentGroupMapping && documentGroupMapping.map(function (documentGroup) {
507
+ if (!documentGroup.parent) {
508
+ return null;
498
509
  }
499
- });
500
- }
501
- if (content_placement && content_placement.length > 0) {
502
- content_placement.filter(function (item) {
503
- return item.path !== 'news';
504
- }).forEach(function (cp) {
510
+
511
+ return React__default.createElement(
512
+ React__default.Fragment,
513
+ null,
514
+ React__default.createElement(
515
+ 'span',
516
+ { className: '' },
517
+ React__default.createElement(
518
+ 'a',
519
+ {
520
+ className: 'related-links',
521
+ style: { color: 'blue' },
522
+ href: cpModificationRequired ? '/' + documentGroup.parent.identifier.current + '/' + documentGroup.path : '/' + documentGroup.path },
523
+ documentGroup.name
524
+ )
525
+ ),
526
+ content_placement && content_placement.length ? ' | ' : null
527
+ );
528
+ }),
529
+ content_placement && content_placement.length > 0 ? content_placement.map(function (cp, index) {
505
530
  var cp_url = cpModificationRequired ? getTargeting.getContentPlacementUrl(cp) : cp.path;
506
531
  var href = '/' + cp_url;
507
- relatedLinks = [].concat(toConsumableArray._toConsumableArray(relatedLinks), [{ label: cp.name, href: href }]);
508
- });
509
- }
510
- if (relatedLinks && relatedLinks.length > 0) {
511
- return React__default.createElement(
512
- 'div',
513
- null,
514
- relatedLinks.map(function (relatedLink, index) {
515
- return React__default.createElement(
532
+ return React__default.createElement(
533
+ React__default.Fragment,
534
+ { key: index },
535
+ React__default.createElement(
516
536
  'span',
517
- { key: index, className: 'related-link' },
537
+ null,
518
538
  React__default.createElement(
519
539
  'a',
520
- { className: 'related-links', style: { color: 'blue' }, href: relatedLink.href },
521
- relatedLink.label
522
- ),
523
- React__default.createElement(
524
- 'style',
525
- { jsx: 'true' },
526
- '\n .related-link:not(:first-child):before {\n content: \' | \';\n }\n '
540
+ { className: 'related-links', key: index, href: href, style: { color: 'blue' } },
541
+ cp.name
527
542
  )
528
- );
529
- })
530
- );
531
- }
532
- return null;
543
+ ),
544
+ content_placement.length > index + 1 ? ' | ' : null
545
+ );
546
+ }) : null
547
+ );
533
548
  }
534
549
  return null;
535
550
  };
536
551
 
537
- var RelatedContent = function RelatedContent() {
538
- return React__default.createElement(
539
- 'section',
540
- { className: 'my-1' },
541
- React__default.createElement(
542
- 'p',
543
- { className: 'mb-0' },
544
- React__default.createElement(
545
- 'b',
546
- null,
547
- 'Related Content:'
548
- )
549
- ),
550
- React__default.createElement(RelevantTopics, null),
551
- React__default.createElement(
552
- 'div',
553
- { className: 'pt-2' },
554
- React__default.createElement(RelatedArticle, { articles: article.relatedArticle, client: client })
555
- )
556
- );
557
- };
558
-
559
552
  var form = function form() {
560
553
  return React__default.createElement(
561
554
  React__default.Fragment,
@@ -1014,7 +1007,20 @@ var Article = function Article(props) {
1014
1007
  )
1015
1008
  ),
1016
1009
  React__default.createElement('div', { className: 'clearfix', style: { minHeight: '1px' } }),
1017
- showRelatedArticles && !showIsi && React__default.createElement(RelatedContent, null)
1010
+ showRelatedArticles && !showIsi && React__default.createElement(
1011
+ React__default.Fragment,
1012
+ null,
1013
+ React__default.createElement(
1014
+ 'div',
1015
+ null,
1016
+ React__default.createElement(RelevantTopics, null)
1017
+ ),
1018
+ React__default.createElement(
1019
+ 'div',
1020
+ { className: 'pt-2' },
1021
+ React__default.createElement(RelatedArticle, { articles: article.relatedArticle, client: client })
1022
+ )
1023
+ )
1018
1024
  ),
1019
1025
  renderIsiContent(props.article)
1020
1026
  ),
@@ -1179,77 +1185,50 @@ var ArticleQueue = function ArticleQueue(props) {
1179
1185
  }, 1000);
1180
1186
  }, [queueData.length]);
1181
1187
 
1182
- var loadmore = function () {
1183
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
1184
- var index, article, startingIndex, endingIndex, targeting;
1185
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
1186
- while (1) {
1187
- switch (_context.prev = _context.next) {
1188
- case 0:
1189
- if (!(queueData && queueData.length < maxListLength)) {
1190
- _context.next = 27;
1191
- break;
1188
+ var loadmore = function loadmore() {
1189
+ var query = props.relatedArticleQuery;
1190
+ var params = props.params;
1191
+ if (queueData && queueData.length < maxListLength) {
1192
+ params.index = queueData.length - 1;
1193
+ props.client.fetch(query, params).then(function () {
1194
+ var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(article) {
1195
+ var startingIndex, endingIndex, targeting;
1196
+ return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
1197
+ while (1) {
1198
+ switch (_context.prev = _context.next) {
1199
+ case 0:
1200
+ if (!(article && article._id)) {
1201
+ _context.next = 9;
1202
+ break;
1203
+ }
1204
+
1205
+ //query next 4 related article without repeating previous 4 related articles
1206
+ startingIndex = queueData.length + 1;
1207
+ endingIndex = startingIndex + 2;
1208
+ _context.next = 5;
1209
+ return getRelatedArticle(null, props.client, article, prevUrl, startingIndex + '..' + endingIndex);
1210
+
1211
+ case 5:
1212
+ article.relatedArticle = _context.sent;
1213
+ targeting = getTargeting.getTargeting({ article: article, cpModificationRequired: cpModificationRequired, prevUrl: prevUrl });
1214
+
1215
+ article.Ads = Ads.getRightItems(targeting);
1216
+ setQueueData([].concat(toConsumableArray._toConsumableArray(queueData), [article]));
1217
+
1218
+ case 9:
1219
+ case 'end':
1220
+ return _context.stop();
1192
1221
  }
1222
+ }
1223
+ }, _callee, _this);
1224
+ }));
1193
1225
 
1194
- index = queueData.length - 1;
1195
- article = null;
1196
- _context.prev = 3;
1197
- _context.next = 6;
1198
- return getRelatedArticle(null, props.client, props.article, prevUrl, index);
1199
-
1200
- case 6:
1201
- article = _context.sent;
1202
- _context.next = 12;
1203
- break;
1204
-
1205
- case 9:
1206
- _context.prev = 9;
1207
- _context.t0 = _context['catch'](3);
1208
-
1209
- console.error(_context.t0);
1210
-
1211
- case 12:
1212
- if (!(article && article._id)) {
1213
- _context.next = 27;
1214
- break;
1215
- }
1216
-
1217
- //query next 4 related article without repeating previous 4 related articles
1218
- startingIndex = queueData.length + 1;
1219
- endingIndex = startingIndex + 2;
1220
- _context.prev = 15;
1221
- _context.next = 18;
1222
- return getRelatedArticle(null, props.client, props.article, prevUrl, startingIndex + '..' + endingIndex);
1223
-
1224
- case 18:
1225
- article.relatedArticle = _context.sent;
1226
- _context.next = 24;
1227
- break;
1228
-
1229
- case 21:
1230
- _context.prev = 21;
1231
- _context.t1 = _context['catch'](15);
1232
-
1233
- console.error(_context.t1);
1234
-
1235
- case 24:
1236
- targeting = getTargeting.getTargeting({ article: article, cpModificationRequired: cpModificationRequired, prevUrl: prevUrl });
1237
-
1238
- article.Ads = Ads.getRightItems(targeting);
1239
- setQueueData([].concat(toConsumableArray._toConsumableArray(queueData), [article]));
1240
-
1241
- case 27:
1242
- case 'end':
1243
- return _context.stop();
1244
- }
1245
- }
1246
- }, _callee, _this, [[3, 9], [15, 21]]);
1247
- }));
1248
-
1249
- return function loadmore() {
1250
- return _ref.apply(this, arguments);
1251
- };
1252
- }();
1226
+ return function (_x) {
1227
+ return _ref.apply(this, arguments);
1228
+ };
1229
+ }());
1230
+ }
1231
+ };
1253
1232
 
1254
1233
  var changeMeta = function changeMeta(meta) {
1255
1234
  document.title = meta.shareTitle;
@@ -1321,6 +1300,74 @@ var ArticleQueue = function ArticleQueue(props) {
1321
1300
  );
1322
1301
  };
1323
1302
 
1303
+ var Articles = function Articles(props) {
1304
+ var _extends2;
1305
+
1306
+ var videoAccountIDs = props.videoAccountIDs,
1307
+ Ads = props.Ads,
1308
+ cpModificationRequired = props.cpModificationRequired,
1309
+ Settings = props.Settings,
1310
+ ISIContent = props.ISIContent,
1311
+ prevUrl = props.prevUrl,
1312
+ setActiveArticle = props.setActiveArticle,
1313
+ article = props.article,
1314
+ client = props.client,
1315
+ relatedArticleQuery = props.relatedArticleQuery,
1316
+ Website = props.Website,
1317
+ pageview = props.pageview,
1318
+ shareOptions = props.shareOptions,
1319
+ WAds = props.WAds,
1320
+ regionalPages = props.regionalPages,
1321
+ nationalPage = props.nationalPage,
1322
+ canonicalTag = props.canonicalTag;
1323
+ var taxonomyMapping = article.taxonomyMapping,
1324
+ _article$url = article.url;
1325
+ _article$url = _article$url === undefined ? {
1326
+ current: null
1327
+ } : _article$url;
1328
+ var url = _article$url.current,
1329
+ content_placement = article.content_placement;
1330
+
1331
+
1332
+ var taxonomy = [];
1333
+ content_placement.forEach(function (_ref2) {
1334
+ var path = _ref2.path,
1335
+ _id = _ref2._id;
1336
+
1337
+ var prev_url_to_check = prevUrl;
1338
+ if (prev_url_to_check.includes('?')) {
1339
+ prev_url_to_check = prev_url_to_check.split('?')[0];
1340
+ }
1341
+ if (prev_url_to_check.endsWith(path)) taxonomy.push(_id);
1342
+ });
1343
+
1344
+ if (taxonomy.length === 0) {
1345
+ taxonomy = taxonomyMapping.map(function (_ref3) {
1346
+ var _ref = _ref3._ref;
1347
+ return _ref;
1348
+ });
1349
+ }
1350
+
1351
+ var params = {
1352
+ url: url,
1353
+ taxonomy: taxonomy,
1354
+ index: 0
1355
+ };
1356
+
1357
+ return React__default.createElement(ArticleQueue, _extends$1._extends((_extends2 = {
1358
+ client: client,
1359
+ params: params,
1360
+ relatedArticleQuery: relatedArticleQuery,
1361
+ website: Website,
1362
+ checkSponsered: true,
1363
+ pageview: pageview,
1364
+ shareOptions: shareOptions,
1365
+ Ads: WAds,
1366
+ regionalPages: regionalPages,
1367
+ nationalPage: nationalPage
1368
+ }, defineProperty$1._defineProperty(_extends2, 'pageview', pageview), defineProperty$1._defineProperty(_extends2, 'onVote', function onVote() {}), defineProperty$1._defineProperty(_extends2, 'ISIContent', ISIContent), defineProperty$1._defineProperty(_extends2, 'videoAccountIDs', videoAccountIDs), defineProperty$1._defineProperty(_extends2, 'sponsoredTaxonomies', []), defineProperty$1._defineProperty(_extends2, 'cpModificationRequired', cpModificationRequired), defineProperty$1._defineProperty(_extends2, 'Settings', Settings), defineProperty$1._defineProperty(_extends2, 'canonicalTag', canonicalTag), _extends2), props));
1369
+ };
1370
+
1324
1371
  var _this$1 = undefined;
1325
1372
 
1326
1373
  var View = function View(props) {
@@ -1499,15 +1546,7 @@ var View = function View(props) {
1499
1546
  props.article.seriesDetail && props.article.seriesDetail.nextUrl && React__default.createElement('link', { rel: 'next', href: props.article.seriesDetail.nextUrl })
1500
1547
  )
1501
1548
  ),
1502
- !needInfiniteScroll ? React__default.createElement(Article, _extends$1._extends({ infiniteScroll: false, showRelatedArticles: showRelatedArticles }, props)) : React__default.createElement(ArticleQueue, _extends$1._extends({
1503
- infiniteScroll: true,
1504
- showRelatedArticles: showRelatedArticles,
1505
- canonicalTag: canonicalTag,
1506
- checkSponsered: true,
1507
- Ads: props.WAds,
1508
- onVote: function onVote() {},
1509
- sponsoredTaxonomies: []
1510
- }, props))
1549
+ !needInfiniteScroll ? React__default.createElement(Article, _extends$1._extends({ infiniteScroll: false, showRelatedArticles: showRelatedArticles }, props)) : React__default.createElement(Articles, _extends$1._extends({ infiniteScroll: true, showRelatedArticles: showRelatedArticles, canonicalTag: canonicalTag }, props))
1511
1550
  );
1512
1551
  };
1513
1552
 
@@ -10,9 +10,9 @@ var getQuery = function getQuery(type) {
10
10
 
11
11
  switch (type) {
12
12
  case 'related':
13
- 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 && 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 ' + conditions + '\n ]| order(published desc)[' + (articleCount ? articleCount : '$index') + ']{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n ...,\n passwordLock,\n password,\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\n body[] {\n ...,\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n }\n },\n \'content_placement\': taxonomyMapping[]-> {\n _id,\n \'ancestor\': parent->parent->identifier,\n \'parent\': parent->identifier,\n \'name\': name,\n \'path\': identifier,\n disableAds\n },\n documentGroup-> {\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n documentGroupMapping[]-> {\n _id,\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n \'issue\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.issueGroup._ref][0] {\n name,\n \'path\': identifier.current,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current\n },\n \'url\' : pdf.asset-> url\n }\n }';
13
+ 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 && 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 ' + conditions + '\n ]| order(published desc)[' + (articleCount ? articleCount : '$index') + ']{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n ...,\n passwordLock,\n password,\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\n body[] {\n ...,\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n }\n },\n \'content_placement\': taxonomyMapping[]-> {\n \'ancestor\': parent->parent->identifier,\n \'parent\': parent->identifier,\n \'name\': name,\n \'path\': identifier,\n disableAds\n },\n documentGroup-> {\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n documentGroupMapping[]-> {\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n \'issue\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.issueGroup._ref][0] {\n name,\n \'path\': identifier.current,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current\n },\n \'url\' : pdf.asset-> url\n }\n }';
14
14
  case 'article':
15
- return '*[\n _type == "article"\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && url.current == $url\n ' + conditions + '\n ][0]{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n ...,\n passwordLock,\n password,\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\n body[] {\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 },\n articles[]{\n ...,\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\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 },\n documentGroup-> {\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n documentGroupMapping[]-> {\n _id,\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\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 \'issueNumber\': number,\n \'articleSource\': source,\n \'path\': identifier.current,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current\n },\n \'url\' : pdf.asset-> url\n }\n\n }';
15
+ return '*[\n _type == "article"\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && url.current == $url\n ' + conditions + '\n ][0]{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n ...,\n passwordLock,\n password,\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\n body[] {\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 },\n articles[]{\n ...,\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\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 },\n documentGroup-> {\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n documentGroupMapping[]-> {\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\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 \'issueNumber\': number,\n \'articleSource\': source,\n \'path\': identifier.current,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current\n },\n \'url\' : pdf.asset-> url\n }\n\n }';
16
16
  case 'publication':
17
17
  return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issues\': *[_type == \'publication\'\n && is_visible\n && references(^._id)\n && defined(identifier)] {\n ...,\n pdf{asset->}\n } | order(year desc, month desc)\n }';
18
18
  case 'issue':
@@ -364,33 +364,28 @@ var dist_3 = dist.parseCookies;
364
364
  var _this = undefined;
365
365
 
366
366
  var getRelatedArticle = function () {
367
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
367
+ var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
368
368
  var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
369
369
  var client = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
370
370
  var article = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
371
371
  var prevUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';
372
372
  var articleCount = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
373
373
 
374
- var _article$url, url, documentGroupMapping, issueGroup, content_placement, references, params, conditions, cookies, prevSlugs, articles, query;
374
+ var taxonomyMapping, _article$url, url, content_placement, taxonomy, params, conditions, cookies, prevSlugs, relatedArticleQuery, relatedArticle;
375
375
 
376
376
  return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
377
377
  while (1) {
378
378
  switch (_context.prev = _context.next) {
379
379
  case 0:
380
- _article$url = article.url;
380
+ taxonomyMapping = article.taxonomyMapping, _article$url = article.url;
381
381
  _article$url = _article$url === undefined ? {
382
382
  current: null
383
383
  } : _article$url;
384
- url = _article$url.current, documentGroupMapping = article.documentGroupMapping, issueGroup = article.issueGroup;
385
- content_placement = article.content_placement;
386
- references = [];
384
+ url = _article$url.current, content_placement = article.content_placement;
385
+ taxonomy = [];
386
+ //404 articles were throwing server error
387
387
 
388
-
389
- content_placement = content_placement && content_placement.length > 0 && content_placement.filter(function (_ref2) {
390
- var identifier = _ref2.identifier;
391
- return identifier !== 'news';
392
- });
393
- if (content_placement && content_placement.length > 0) {
388
+ if (content_placement) {
394
389
  content_placement.forEach(function (_ref3) {
395
390
  var path = _ref3.path,
396
391
  _id = _ref3._id;
@@ -402,30 +397,26 @@ var getRelatedArticle = function () {
402
397
  if (prev_url_to_check.includes('?')) {
403
398
  prev_url_to_check = prev_url_to_check.split('?')[0];
404
399
  }
405
- if (prev_url_to_check.endsWith(path) && _id) references.push(_id);
400
+ if (prev_url_to_check.endsWith(path) && _id) taxonomy.push(_id);
406
401
  });
407
- if (references.length === 0) {
408
- content_placement.forEach(function (_ref4) {
409
- var _id = _ref4._id;
410
-
411
- if (_id) references.push(_id);
412
- });
413
- }
414
402
  }
415
403
 
416
- if (documentGroupMapping && documentGroupMapping.length > 0) {
417
- documentGroupMapping.forEach(function (_ref5) {
418
- var _id = _ref5._id;
404
+ //404 articles were throwing server error
405
+ if (taxonomy.length === 0 && taxonomyMapping) {
406
+ taxonomyMapping.forEach(function (_ref4) {
407
+ var _ref = _ref4._ref;
419
408
 
420
- if (_id) references.push(_id);
409
+ if (_ref) {
410
+ taxonomy.push(_ref);
411
+ }
421
412
  });
422
413
  }
423
414
 
424
- if (issueGroup && issueGroup._ref) {
425
- references.push(issueGroup._ref);
426
- }
427
-
428
- params = { url: url, references: references, index: articleCount };
415
+ params = {
416
+ url: url,
417
+ taxonomy: taxonomy,
418
+ index: articleCount
419
+ };
429
420
  conditions = '';
430
421
 
431
422
  if (ctx && url) {
@@ -437,43 +428,24 @@ var getRelatedArticle = function () {
437
428
  conditions = '&& !(url.current in [' + prevSlugs + '])';
438
429
  } else dist_2(ctx, 'prevSlugs', '"' + url + '"', {});
439
430
  }
431
+ relatedArticleQuery = getQuery('related', conditions, '', articleCount);
432
+ _context.next = 12;
433
+ return client.fetch(relatedArticleQuery, params);
440
434
 
441
- articles = null;
442
-
443
- if (!(params.references && params.references.length > 0)) {
444
- _context.next = 24;
445
- break;
446
- }
447
-
448
- query = getQuery('related', conditions, '', articleCount).replace('&& taxonomyMapping[]._ref in $taxonomy', '&& references($references)');
449
- _context.prev = 15;
450
- _context.next = 18;
451
- return client.fetch(query, params);
452
-
453
- case 18:
454
- articles = _context.sent;
455
- _context.next = 24;
456
- break;
457
-
458
- case 21:
459
- _context.prev = 21;
460
- _context.t0 = _context['catch'](15);
461
-
462
- console.error(_context.t0);
463
-
464
- case 24:
465
- return _context.abrupt('return', articles);
435
+ case 12:
436
+ relatedArticle = _context.sent;
437
+ return _context.abrupt('return', relatedArticle);
466
438
 
467
- case 25:
439
+ case 14:
468
440
  case 'end':
469
441
  return _context.stop();
470
442
  }
471
443
  }
472
- }, _callee, _this, [[15, 21]]);
444
+ }, _callee, _this);
473
445
  }));
474
446
 
475
447
  return function getRelatedArticle() {
476
- return _ref.apply(this, arguments);
448
+ return _ref2.apply(this, arguments);
477
449
  };
478
450
  }();
479
451