@mjhls/mjh-framework 1.0.700 → 1.0.701

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- # mjh-framework v. 1.0.700
2
+ # mjh-framework v. 1.0.701
3
3
 
4
4
  > Foundation Framework
5
5
 
package/dist/cjs/View.js CHANGED
@@ -48,7 +48,6 @@ 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');
52
51
  var Form = _interopDefault(require('react-bootstrap/Form'));
53
52
  var getSerializers = require('./index-ec02006c.js');
54
53
  require('./util-f2c1b65b.js');
@@ -255,7 +254,7 @@ var ISI = function ISI(props) {
255
254
  );
256
255
  };
257
256
 
258
- 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
+ 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";
259
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" };
260
259
  styleInject_es.styleInject(css);
261
260
 
@@ -383,6 +382,7 @@ var Article = function Article(props) {
383
382
  issue = _props$article.issue,
384
383
  source = _props$article.source,
385
384
  documentGroupMapping = _props$article.documentGroupMapping,
385
+ issueGroup = _props$article.issueGroup,
386
386
  showIsi = _props$article.showIsi,
387
387
  isi = _props$article.isi,
388
388
  regionalPages = props.regionalPages,
@@ -493,65 +493,76 @@ var Article = function Article(props) {
493
493
  };
494
494
 
495
495
  var RelevantTopics = function RelevantTopics() {
496
- if (content_placement && content_placement.length > 0 || documentGroupMapping) {
497
- return React__default.createElement(
498
- 'div',
499
- { style: { color: '#262626' } },
500
- React__default.createElement(
501
- 'p',
502
- { className: 'mb-0' },
503
- React__default.createElement(
504
- 'b',
505
- null,
506
- 'Related Content:'
507
- )
508
- ),
509
- documentGroupMapping && documentGroupMapping.map(function (documentGroup) {
510
- if (!documentGroup.parent) {
511
- return null;
496
+ if (content_placement && content_placement.length > 0 || documentGroupMapping && documentGroupMapping.length > 0) {
497
+ var relatedLinks = [];
498
+ if (documentGroupMapping && documentGroupMapping.length > 0) {
499
+ documentGroupMapping.forEach(function (documentGroup) {
500
+ if (documentGroup.parent) {
501
+ relatedLinks = [].concat(toConsumableArray._toConsumableArray(relatedLinks), [{ label: documentGroup.name, href: cpModificationRequired ? '/' + documentGroup.parent.identifier.current + '/' + documentGroup.path : '/' + documentGroup.path }]);
512
502
  }
513
-
514
- return React__default.createElement(
515
- React__default.Fragment,
516
- null,
517
- React__default.createElement(
518
- 'span',
519
- { className: '' },
520
- React__default.createElement(
521
- 'a',
522
- {
523
- className: 'related-links',
524
- style: { color: 'blue' },
525
- href: cpModificationRequired ? '/' + documentGroup.parent.identifier.current + '/' + documentGroup.path : '/' + documentGroup.path },
526
- documentGroup.name
527
- )
528
- ),
529
- content_placement && content_placement.length ? ' | ' : null
530
- );
531
- }),
532
- content_placement && content_placement.length > 0 ? content_placement.map(function (cp, index) {
503
+ });
504
+ }
505
+ if (content_placement && content_placement.length > 0) {
506
+ content_placement.filter(function (item) {
507
+ return item.path !== 'news';
508
+ }).forEach(function (cp) {
533
509
  var cp_url = cpModificationRequired ? getTargeting.getContentPlacementUrl(cp) : cp.path;
534
510
  var href = '/' + cp_url;
535
- return React__default.createElement(
536
- React__default.Fragment,
537
- { key: index },
538
- React__default.createElement(
511
+ relatedLinks = [].concat(toConsumableArray._toConsumableArray(relatedLinks), [{ label: cp.name, href: href }]);
512
+ });
513
+ }
514
+ if (issueGroup && issueGroup.name && issueGroup.identifier && issueGroup.identifier.current && issueGroup.parent && issueGroup.parent.identifier && issueGroup.parent.identifier.current) {
515
+ relatedLinks = [].concat(toConsumableArray._toConsumableArray(relatedLinks), [{ label: issueGroup.name, href: '/publications/' + issueGroup.parent.identifier.current + '/' + issueGroup.identifier.current }]);
516
+ }
517
+ if (relatedLinks && relatedLinks.length > 0) {
518
+ return React__default.createElement(
519
+ 'div',
520
+ null,
521
+ relatedLinks.map(function (relatedLink, index) {
522
+ return React__default.createElement(
539
523
  'span',
540
- null,
524
+ { key: index, className: 'related-link' },
541
525
  React__default.createElement(
542
526
  'a',
543
- { className: 'related-links', key: index, href: href, style: { color: 'blue' } },
544
- cp.name
527
+ { className: 'related-links', style: { color: 'blue' }, href: relatedLink.href },
528
+ relatedLink.label
529
+ ),
530
+ React__default.createElement(
531
+ 'style',
532
+ { jsx: 'true' },
533
+ '\n .related-link:not(:first-child):before {\n content: \' | \';\n }\n '
545
534
  )
546
- ),
547
- content_placement.length > index + 1 ? ' | ' : null
548
- );
549
- }) : null
550
- );
535
+ );
536
+ })
537
+ );
538
+ }
539
+ return null;
551
540
  }
552
541
  return null;
553
542
  };
554
543
 
544
+ var RelatedContent = function RelatedContent() {
545
+ return React__default.createElement(
546
+ 'section',
547
+ { id: 'related-content-section', className: 'my-1' },
548
+ React__default.createElement(
549
+ 'p',
550
+ { className: 'mb-0' },
551
+ React__default.createElement(
552
+ 'b',
553
+ null,
554
+ 'Related Content:'
555
+ )
556
+ ),
557
+ React__default.createElement(RelevantTopics, null),
558
+ React__default.createElement(
559
+ 'div',
560
+ { className: 'pt-2' },
561
+ React__default.createElement(RelatedArticle, { articles: article.relatedArticle, client: client })
562
+ )
563
+ );
564
+ };
565
+
555
566
  var form = function form() {
556
567
  return React__default.createElement(
557
568
  React__default.Fragment,
@@ -1010,20 +1021,7 @@ var Article = function Article(props) {
1010
1021
  )
1011
1022
  ),
1012
1023
  React__default.createElement('div', { className: 'clearfix', style: { minHeight: '1px' } }),
1013
- showRelatedArticles && !showIsi && React__default.createElement(
1014
- React__default.Fragment,
1015
- null,
1016
- React__default.createElement(
1017
- 'div',
1018
- null,
1019
- React__default.createElement(RelevantTopics, null)
1020
- ),
1021
- React__default.createElement(
1022
- 'div',
1023
- { className: 'pt-2' },
1024
- React__default.createElement(RelatedArticle, { articles: article.relatedArticle, client: client })
1025
- )
1026
- )
1024
+ showRelatedArticles && !showIsi && React__default.createElement(RelatedContent, null)
1027
1025
  ),
1028
1026
  renderIsiContent(props.article)
1029
1027
  ),
@@ -1188,50 +1186,77 @@ var ArticleQueue = function ArticleQueue(props) {
1188
1186
  }, 1000);
1189
1187
  }, [queueData.length]);
1190
1188
 
1191
- var loadmore = function loadmore() {
1192
- var query = props.relatedArticleQuery;
1193
- var params = props.params;
1194
- if (queueData && queueData.length < maxListLength) {
1195
- params.index = queueData.length - 1;
1196
- props.client.fetch(query, params).then(function () {
1197
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(article) {
1198
- var startingIndex, endingIndex, targeting;
1199
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
1200
- while (1) {
1201
- switch (_context.prev = _context.next) {
1202
- case 0:
1203
- if (!(article && article._id)) {
1204
- _context.next = 9;
1205
- break;
1206
- }
1207
-
1208
- //query next 4 related article without repeating previous 4 related articles
1209
- startingIndex = queueData.length + 1;
1210
- endingIndex = startingIndex + 2;
1211
- _context.next = 5;
1212
- return getRelatedArticle(null, props.client, article, prevUrl, startingIndex + '..' + endingIndex);
1213
-
1214
- case 5:
1215
- article.relatedArticle = _context.sent;
1216
- targeting = getTargeting.getTargeting({ article: article, cpModificationRequired: cpModificationRequired, prevUrl: prevUrl });
1217
-
1218
- article.Ads = Ads.getRightItems(targeting);
1219
- setQueueData([].concat(toConsumableArray._toConsumableArray(queueData), [article]));
1220
-
1221
- case 9:
1222
- case 'end':
1223
- return _context.stop();
1189
+ var loadmore = function () {
1190
+ var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
1191
+ var index, article, startingIndex, endingIndex, targeting;
1192
+ return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
1193
+ while (1) {
1194
+ switch (_context.prev = _context.next) {
1195
+ case 0:
1196
+ if (!(queueData && queueData.length < maxListLength)) {
1197
+ _context.next = 27;
1198
+ break;
1224
1199
  }
1225
- }
1226
- }, _callee, _this);
1227
- }));
1228
1200
 
1229
- return function (_x) {
1230
- return _ref.apply(this, arguments);
1231
- };
1232
- }());
1233
- }
1234
- };
1201
+ index = queueData.length - 1;
1202
+ article = null;
1203
+ _context.prev = 3;
1204
+ _context.next = 6;
1205
+ return getRelatedArticle(null, props.client, props.article, prevUrl, index);
1206
+
1207
+ case 6:
1208
+ article = _context.sent;
1209
+ _context.next = 12;
1210
+ break;
1211
+
1212
+ case 9:
1213
+ _context.prev = 9;
1214
+ _context.t0 = _context['catch'](3);
1215
+
1216
+ console.error(_context.t0);
1217
+
1218
+ case 12:
1219
+ if (!(article && article._id)) {
1220
+ _context.next = 27;
1221
+ break;
1222
+ }
1223
+
1224
+ //query next 4 related article without repeating previous 4 related articles
1225
+ startingIndex = queueData.length + 1;
1226
+ endingIndex = startingIndex + 2;
1227
+ _context.prev = 15;
1228
+ _context.next = 18;
1229
+ return getRelatedArticle(null, props.client, props.article, prevUrl, startingIndex + '..' + endingIndex);
1230
+
1231
+ case 18:
1232
+ article.relatedArticle = _context.sent;
1233
+ _context.next = 24;
1234
+ break;
1235
+
1236
+ case 21:
1237
+ _context.prev = 21;
1238
+ _context.t1 = _context['catch'](15);
1239
+
1240
+ console.error(_context.t1);
1241
+
1242
+ case 24:
1243
+ targeting = getTargeting.getTargeting({ article: article, cpModificationRequired: cpModificationRequired, prevUrl: prevUrl });
1244
+
1245
+ article.Ads = Ads.getRightItems(targeting);
1246
+ setQueueData([].concat(toConsumableArray._toConsumableArray(queueData), [article]));
1247
+
1248
+ case 27:
1249
+ case 'end':
1250
+ return _context.stop();
1251
+ }
1252
+ }
1253
+ }, _callee, _this, [[3, 9], [15, 21]]);
1254
+ }));
1255
+
1256
+ return function loadmore() {
1257
+ return _ref.apply(this, arguments);
1258
+ };
1259
+ }();
1235
1260
 
1236
1261
  var changeMeta = function changeMeta(meta) {
1237
1262
  document.title = meta.shareTitle;
@@ -1303,74 +1328,6 @@ var ArticleQueue = function ArticleQueue(props) {
1303
1328
  );
1304
1329
  };
1305
1330
 
1306
- var Articles = function Articles(props) {
1307
- var _extends2;
1308
-
1309
- var videoAccountIDs = props.videoAccountIDs,
1310
- Ads = props.Ads,
1311
- cpModificationRequired = props.cpModificationRequired,
1312
- Settings = props.Settings,
1313
- ISIContent = props.ISIContent,
1314
- prevUrl = props.prevUrl,
1315
- setActiveArticle = props.setActiveArticle,
1316
- article = props.article,
1317
- client = props.client,
1318
- relatedArticleQuery = props.relatedArticleQuery,
1319
- Website = props.Website,
1320
- pageview = props.pageview,
1321
- shareOptions = props.shareOptions,
1322
- WAds = props.WAds,
1323
- regionalPages = props.regionalPages,
1324
- nationalPage = props.nationalPage,
1325
- canonicalTag = props.canonicalTag;
1326
- var taxonomyMapping = article.taxonomyMapping,
1327
- _article$url = article.url;
1328
- _article$url = _article$url === undefined ? {
1329
- current: null
1330
- } : _article$url;
1331
- var url = _article$url.current,
1332
- content_placement = article.content_placement;
1333
-
1334
-
1335
- var taxonomy = [];
1336
- content_placement.forEach(function (_ref2) {
1337
- var path = _ref2.path,
1338
- _id = _ref2._id;
1339
-
1340
- var prev_url_to_check = prevUrl;
1341
- if (prev_url_to_check.includes('?')) {
1342
- prev_url_to_check = prev_url_to_check.split('?')[0];
1343
- }
1344
- if (prev_url_to_check.endsWith(path)) taxonomy.push(_id);
1345
- });
1346
-
1347
- if (taxonomy.length === 0) {
1348
- taxonomy = taxonomyMapping.map(function (_ref3) {
1349
- var _ref = _ref3._ref;
1350
- return _ref;
1351
- });
1352
- }
1353
-
1354
- var params = {
1355
- url: url,
1356
- taxonomy: taxonomy,
1357
- index: 0
1358
- };
1359
-
1360
- return React__default.createElement(ArticleQueue, _extends._extends((_extends2 = {
1361
- client: client,
1362
- params: params,
1363
- relatedArticleQuery: relatedArticleQuery,
1364
- website: Website,
1365
- checkSponsered: true,
1366
- pageview: pageview,
1367
- shareOptions: shareOptions,
1368
- Ads: WAds,
1369
- regionalPages: regionalPages,
1370
- nationalPage: nationalPage
1371
- }, 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));
1372
- };
1373
-
1374
1331
  var _this$1 = undefined;
1375
1332
 
1376
1333
  var View = function View(props) {
@@ -1549,7 +1506,15 @@ var View = function View(props) {
1549
1506
  props.article.seriesDetail && props.article.seriesDetail.nextUrl && React__default.createElement('link', { rel: 'next', href: props.article.seriesDetail.nextUrl })
1550
1507
  )
1551
1508
  ),
1552
- !needInfiniteScroll ? React__default.createElement(Article, _extends._extends({ infiniteScroll: false, showRelatedArticles: showRelatedArticles }, props)) : React__default.createElement(Articles, _extends._extends({ infiniteScroll: true, showRelatedArticles: showRelatedArticles, canonicalTag: canonicalTag }, props))
1509
+ !needInfiniteScroll ? React__default.createElement(Article, _extends._extends({ infiniteScroll: false, showRelatedArticles: showRelatedArticles }, props)) : React__default.createElement(ArticleQueue, _extends._extends({
1510
+ infiniteScroll: true,
1511
+ showRelatedArticles: showRelatedArticles,
1512
+ canonicalTag: canonicalTag,
1513
+ checkSponsered: true,
1514
+ Ads: props.WAds,
1515
+ onVote: function onVote() {},
1516
+ sponsoredTaxonomies: []
1517
+ }, props))
1553
1518
  );
1554
1519
  };
1555
1520
 
@@ -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 \'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 }';
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 }';
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 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 issueGroup-> { _id, name, identifier, parent-> },\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 }';
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':
@@ -426,28 +426,33 @@ var dist_3 = dist.parseCookies;
426
426
  var _this = undefined;
427
427
 
428
428
  var getRelatedArticle = function () {
429
- var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
429
+ var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
430
430
  var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
431
431
  var client = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
432
432
  var article = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
433
433
  var prevUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';
434
434
  var articleCount = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
435
435
 
436
- var taxonomyMapping, _article$url, url, content_placement, taxonomy, params, conditions, cookies, prevSlugs, relatedArticleQuery, relatedArticle;
436
+ var _article$url, url, documentGroupMapping, issueGroup, content_placement, references, params, articles, filters, cookies, prevSlugs, query;
437
437
 
438
438
  return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
439
439
  while (1) {
440
440
  switch (_context.prev = _context.next) {
441
441
  case 0:
442
- taxonomyMapping = article.taxonomyMapping, _article$url = article.url;
442
+ _article$url = article.url;
443
443
  _article$url = _article$url === undefined ? {
444
444
  current: null
445
445
  } : _article$url;
446
- url = _article$url.current, content_placement = article.content_placement;
447
- taxonomy = [];
448
- //404 articles were throwing server error
446
+ url = _article$url.current, documentGroupMapping = article.documentGroupMapping, issueGroup = article.issueGroup;
447
+ content_placement = article.content_placement;
448
+ references = [];
449
449
 
450
- if (content_placement) {
450
+
451
+ content_placement = content_placement && content_placement.length > 0 && content_placement.filter(function (_ref2) {
452
+ var identifier = _ref2.identifier;
453
+ return identifier !== 'news';
454
+ });
455
+ if (content_placement && content_placement.length > 0) {
451
456
  content_placement.forEach(function (_ref3) {
452
457
  var path = _ref3.path,
453
458
  _id = _ref3._id;
@@ -459,27 +464,39 @@ var getRelatedArticle = function () {
459
464
  if (prev_url_to_check.includes('?')) {
460
465
  prev_url_to_check = prev_url_to_check.split('?')[0];
461
466
  }
462
- if (prev_url_to_check.endsWith(path) && _id) taxonomy.push(_id);
467
+ if (prev_url_to_check.endsWith(path) && _id) references.push(_id);
463
468
  });
469
+ if (references.length === 0) {
470
+ content_placement.forEach(function (_ref4) {
471
+ var _id = _ref4._id;
472
+
473
+ if (_id) references.push(_id);
474
+ });
475
+ }
464
476
  }
465
477
 
466
- //404 articles were throwing server error
467
- if (taxonomy.length === 0 && taxonomyMapping) {
468
- taxonomyMapping.forEach(function (_ref4) {
469
- var _ref = _ref4._ref;
478
+ if (documentGroupMapping && documentGroupMapping.length > 0) {
479
+ documentGroupMapping.forEach(function (_ref5) {
480
+ var _id = _ref5._id;
470
481
 
471
- if (_ref) {
472
- taxonomy.push(_ref);
473
- }
482
+ if (_id) references.push(_id);
474
483
  });
475
484
  }
476
485
 
477
- params = {
478
- url: url,
479
- taxonomy: taxonomy,
480
- index: articleCount
481
- };
482
- conditions = '';
486
+ if (issueGroup && issueGroup._id) {
487
+ references.push(issueGroup._id);
488
+ }
489
+
490
+ params = { url: url, index: articleCount };
491
+ articles = null;
492
+
493
+ if (!(references && references.length > 0)) {
494
+ _context.next = 24;
495
+ break;
496
+ }
497
+
498
+ filters = '&& references("' + references.join('","') + '") ';
499
+
483
500
 
484
501
  if (ctx && url) {
485
502
  cookies = dist_3(ctx);
@@ -487,27 +504,39 @@ var getRelatedArticle = function () {
487
504
 
488
505
  if (!!prevSlugs) {
489
506
  dist_2(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"', {});
490
- conditions = '&& !(url.current in [' + prevSlugs + '])';
507
+ filters = '&& !(url.current in [' + prevSlugs + '])';
491
508
  } else dist_2(ctx, 'prevSlugs', '"' + url + '"', {});
492
509
  }
493
- relatedArticleQuery = getQuery('related', conditions, '', articleCount);
494
- _context.next = 12;
495
- return client.fetch(relatedArticleQuery, params);
496
510
 
497
- case 12:
498
- relatedArticle = _context.sent;
499
- return _context.abrupt('return', relatedArticle);
511
+ query = getQuery('related', filters, '', articleCount).replace('&& taxonomyMapping[]._ref in $taxonomy', '');
512
+ _context.prev = 15;
513
+ _context.next = 18;
514
+ return client.fetch(query, params);
515
+
516
+ case 18:
517
+ articles = _context.sent;
518
+ _context.next = 24;
519
+ break;
520
+
521
+ case 21:
522
+ _context.prev = 21;
523
+ _context.t0 = _context['catch'](15);
524
+
525
+ console.error(_context.t0);
526
+
527
+ case 24:
528
+ return _context.abrupt('return', articles);
500
529
 
501
- case 14:
530
+ case 25:
502
531
  case 'end':
503
532
  return _context.stop();
504
533
  }
505
534
  }
506
- }, _callee, _this);
535
+ }, _callee, _this, [[15, 21]]);
507
536
  }));
508
537
 
509
538
  return function getRelatedArticle() {
510
- return _ref2.apply(this, arguments);
539
+ return _ref.apply(this, arguments);
511
540
  };
512
541
  }();
513
542
 
package/dist/esm/View.js CHANGED
@@ -42,7 +42,6 @@ import 'react-bootstrap';
42
42
  import './iconBase-602d52fe.js';
43
43
  import './index.esm-29e48d38.js';
44
44
  import Button from 'react-bootstrap/Button';
45
- import { _ as _defineProperty } from './defineProperty-b798470d.js';
46
45
  import Form from 'react-bootstrap/Form';
47
46
  import { I as InscreenSensor, r as renderAuthor, g as getSerializers } from './index-50d0fbc7.js';
48
47
  import './util-7700fc59.js';
@@ -249,7 +248,7 @@ var ISI = function ISI(props) {
249
248
  );
250
249
  };
251
250
 
252
- 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";
251
+ 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";
253
252
  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" };
254
253
  styleInject(css);
255
254
 
@@ -377,6 +376,7 @@ var Article = function Article(props) {
377
376
  issue = _props$article.issue,
378
377
  source = _props$article.source,
379
378
  documentGroupMapping = _props$article.documentGroupMapping,
379
+ issueGroup = _props$article.issueGroup,
380
380
  showIsi = _props$article.showIsi,
381
381
  isi = _props$article.isi,
382
382
  regionalPages = props.regionalPages,
@@ -487,65 +487,76 @@ var Article = function Article(props) {
487
487
  };
488
488
 
489
489
  var RelevantTopics = function RelevantTopics() {
490
- if (content_placement && content_placement.length > 0 || documentGroupMapping) {
491
- return React__default.createElement(
492
- 'div',
493
- { style: { color: '#262626' } },
494
- React__default.createElement(
495
- 'p',
496
- { className: 'mb-0' },
497
- React__default.createElement(
498
- 'b',
499
- null,
500
- 'Related Content:'
501
- )
502
- ),
503
- documentGroupMapping && documentGroupMapping.map(function (documentGroup) {
504
- if (!documentGroup.parent) {
505
- return null;
490
+ if (content_placement && content_placement.length > 0 || documentGroupMapping && documentGroupMapping.length > 0) {
491
+ var relatedLinks = [];
492
+ if (documentGroupMapping && documentGroupMapping.length > 0) {
493
+ documentGroupMapping.forEach(function (documentGroup) {
494
+ if (documentGroup.parent) {
495
+ relatedLinks = [].concat(_toConsumableArray(relatedLinks), [{ label: documentGroup.name, href: cpModificationRequired ? '/' + documentGroup.parent.identifier.current + '/' + documentGroup.path : '/' + documentGroup.path }]);
506
496
  }
507
-
508
- return React__default.createElement(
509
- React__default.Fragment,
510
- null,
511
- React__default.createElement(
512
- 'span',
513
- { className: '' },
514
- React__default.createElement(
515
- 'a',
516
- {
517
- className: 'related-links',
518
- style: { color: 'blue' },
519
- href: cpModificationRequired ? '/' + documentGroup.parent.identifier.current + '/' + documentGroup.path : '/' + documentGroup.path },
520
- documentGroup.name
521
- )
522
- ),
523
- content_placement && content_placement.length ? ' | ' : null
524
- );
525
- }),
526
- content_placement && content_placement.length > 0 ? content_placement.map(function (cp, index) {
497
+ });
498
+ }
499
+ if (content_placement && content_placement.length > 0) {
500
+ content_placement.filter(function (item) {
501
+ return item.path !== 'news';
502
+ }).forEach(function (cp) {
527
503
  var cp_url = cpModificationRequired ? getContentPlacementUrl(cp) : cp.path;
528
504
  var href = '/' + cp_url;
529
- return React__default.createElement(
530
- React__default.Fragment,
531
- { key: index },
532
- React__default.createElement(
505
+ relatedLinks = [].concat(_toConsumableArray(relatedLinks), [{ label: cp.name, href: href }]);
506
+ });
507
+ }
508
+ if (issueGroup && issueGroup.name && issueGroup.identifier && issueGroup.identifier.current && issueGroup.parent && issueGroup.parent.identifier && issueGroup.parent.identifier.current) {
509
+ relatedLinks = [].concat(_toConsumableArray(relatedLinks), [{ label: issueGroup.name, href: '/publications/' + issueGroup.parent.identifier.current + '/' + issueGroup.identifier.current }]);
510
+ }
511
+ if (relatedLinks && relatedLinks.length > 0) {
512
+ return React__default.createElement(
513
+ 'div',
514
+ null,
515
+ relatedLinks.map(function (relatedLink, index) {
516
+ return React__default.createElement(
533
517
  'span',
534
- null,
518
+ { key: index, className: 'related-link' },
535
519
  React__default.createElement(
536
520
  'a',
537
- { className: 'related-links', key: index, href: href, style: { color: 'blue' } },
538
- cp.name
521
+ { className: 'related-links', style: { color: 'blue' }, href: relatedLink.href },
522
+ relatedLink.label
523
+ ),
524
+ React__default.createElement(
525
+ 'style',
526
+ { jsx: 'true' },
527
+ '\n .related-link:not(:first-child):before {\n content: \' | \';\n }\n '
539
528
  )
540
- ),
541
- content_placement.length > index + 1 ? ' | ' : null
542
- );
543
- }) : null
544
- );
529
+ );
530
+ })
531
+ );
532
+ }
533
+ return null;
545
534
  }
546
535
  return null;
547
536
  };
548
537
 
538
+ var RelatedContent = function RelatedContent() {
539
+ return React__default.createElement(
540
+ 'section',
541
+ { id: 'related-content-section', className: 'my-1' },
542
+ React__default.createElement(
543
+ 'p',
544
+ { className: 'mb-0' },
545
+ React__default.createElement(
546
+ 'b',
547
+ null,
548
+ 'Related Content:'
549
+ )
550
+ ),
551
+ React__default.createElement(RelevantTopics, null),
552
+ React__default.createElement(
553
+ 'div',
554
+ { className: 'pt-2' },
555
+ React__default.createElement(RelatedArticle, { articles: article.relatedArticle, client: client })
556
+ )
557
+ );
558
+ };
559
+
549
560
  var form = function form() {
550
561
  return React__default.createElement(
551
562
  React__default.Fragment,
@@ -1004,20 +1015,7 @@ var Article = function Article(props) {
1004
1015
  )
1005
1016
  ),
1006
1017
  React__default.createElement('div', { className: 'clearfix', style: { minHeight: '1px' } }),
1007
- showRelatedArticles && !showIsi && React__default.createElement(
1008
- React__default.Fragment,
1009
- null,
1010
- React__default.createElement(
1011
- 'div',
1012
- null,
1013
- React__default.createElement(RelevantTopics, null)
1014
- ),
1015
- React__default.createElement(
1016
- 'div',
1017
- { className: 'pt-2' },
1018
- React__default.createElement(RelatedArticle, { articles: article.relatedArticle, client: client })
1019
- )
1020
- )
1018
+ showRelatedArticles && !showIsi && React__default.createElement(RelatedContent, null)
1021
1019
  ),
1022
1020
  renderIsiContent(props.article)
1023
1021
  ),
@@ -1182,50 +1180,77 @@ var ArticleQueue = function ArticleQueue(props) {
1182
1180
  }, 1000);
1183
1181
  }, [queueData.length]);
1184
1182
 
1185
- var loadmore = function loadmore() {
1186
- var query = props.relatedArticleQuery;
1187
- var params = props.params;
1188
- if (queueData && queueData.length < maxListLength) {
1189
- params.index = queueData.length - 1;
1190
- props.client.fetch(query, params).then(function () {
1191
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(article) {
1192
- var startingIndex, endingIndex, targeting;
1193
- return regenerator.wrap(function _callee$(_context) {
1194
- while (1) {
1195
- switch (_context.prev = _context.next) {
1196
- case 0:
1197
- if (!(article && article._id)) {
1198
- _context.next = 9;
1199
- break;
1200
- }
1201
-
1202
- //query next 4 related article without repeating previous 4 related articles
1203
- startingIndex = queueData.length + 1;
1204
- endingIndex = startingIndex + 2;
1205
- _context.next = 5;
1206
- return getRelatedArticle(null, props.client, article, prevUrl, startingIndex + '..' + endingIndex);
1207
-
1208
- case 5:
1209
- article.relatedArticle = _context.sent;
1210
- targeting = getTargeting({ article: article, cpModificationRequired: cpModificationRequired, prevUrl: prevUrl });
1211
-
1212
- article.Ads = Ads.getRightItems(targeting);
1213
- setQueueData([].concat(_toConsumableArray(queueData), [article]));
1214
-
1215
- case 9:
1216
- case 'end':
1217
- return _context.stop();
1183
+ var loadmore = function () {
1184
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
1185
+ var index, article, startingIndex, endingIndex, targeting;
1186
+ return regenerator.wrap(function _callee$(_context) {
1187
+ while (1) {
1188
+ switch (_context.prev = _context.next) {
1189
+ case 0:
1190
+ if (!(queueData && queueData.length < maxListLength)) {
1191
+ _context.next = 27;
1192
+ break;
1218
1193
  }
1219
- }
1220
- }, _callee, _this);
1221
- }));
1222
1194
 
1223
- return function (_x) {
1224
- return _ref.apply(this, arguments);
1225
- };
1226
- }());
1227
- }
1228
- };
1195
+ index = queueData.length - 1;
1196
+ article = null;
1197
+ _context.prev = 3;
1198
+ _context.next = 6;
1199
+ return getRelatedArticle(null, props.client, props.article, prevUrl, index);
1200
+
1201
+ case 6:
1202
+ article = _context.sent;
1203
+ _context.next = 12;
1204
+ break;
1205
+
1206
+ case 9:
1207
+ _context.prev = 9;
1208
+ _context.t0 = _context['catch'](3);
1209
+
1210
+ console.error(_context.t0);
1211
+
1212
+ case 12:
1213
+ if (!(article && article._id)) {
1214
+ _context.next = 27;
1215
+ break;
1216
+ }
1217
+
1218
+ //query next 4 related article without repeating previous 4 related articles
1219
+ startingIndex = queueData.length + 1;
1220
+ endingIndex = startingIndex + 2;
1221
+ _context.prev = 15;
1222
+ _context.next = 18;
1223
+ return getRelatedArticle(null, props.client, props.article, prevUrl, startingIndex + '..' + endingIndex);
1224
+
1225
+ case 18:
1226
+ article.relatedArticle = _context.sent;
1227
+ _context.next = 24;
1228
+ break;
1229
+
1230
+ case 21:
1231
+ _context.prev = 21;
1232
+ _context.t1 = _context['catch'](15);
1233
+
1234
+ console.error(_context.t1);
1235
+
1236
+ case 24:
1237
+ targeting = getTargeting({ article: article, cpModificationRequired: cpModificationRequired, prevUrl: prevUrl });
1238
+
1239
+ article.Ads = Ads.getRightItems(targeting);
1240
+ setQueueData([].concat(_toConsumableArray(queueData), [article]));
1241
+
1242
+ case 27:
1243
+ case 'end':
1244
+ return _context.stop();
1245
+ }
1246
+ }
1247
+ }, _callee, _this, [[3, 9], [15, 21]]);
1248
+ }));
1249
+
1250
+ return function loadmore() {
1251
+ return _ref.apply(this, arguments);
1252
+ };
1253
+ }();
1229
1254
 
1230
1255
  var changeMeta = function changeMeta(meta) {
1231
1256
  document.title = meta.shareTitle;
@@ -1297,74 +1322,6 @@ var ArticleQueue = function ArticleQueue(props) {
1297
1322
  );
1298
1323
  };
1299
1324
 
1300
- var Articles = function Articles(props) {
1301
- var _extends2;
1302
-
1303
- var videoAccountIDs = props.videoAccountIDs,
1304
- Ads = props.Ads,
1305
- cpModificationRequired = props.cpModificationRequired,
1306
- Settings = props.Settings,
1307
- ISIContent = props.ISIContent,
1308
- prevUrl = props.prevUrl,
1309
- setActiveArticle = props.setActiveArticle,
1310
- article = props.article,
1311
- client = props.client,
1312
- relatedArticleQuery = props.relatedArticleQuery,
1313
- Website = props.Website,
1314
- pageview = props.pageview,
1315
- shareOptions = props.shareOptions,
1316
- WAds = props.WAds,
1317
- regionalPages = props.regionalPages,
1318
- nationalPage = props.nationalPage,
1319
- canonicalTag = props.canonicalTag;
1320
- var taxonomyMapping = article.taxonomyMapping,
1321
- _article$url = article.url;
1322
- _article$url = _article$url === undefined ? {
1323
- current: null
1324
- } : _article$url;
1325
- var url = _article$url.current,
1326
- content_placement = article.content_placement;
1327
-
1328
-
1329
- var taxonomy = [];
1330
- content_placement.forEach(function (_ref2) {
1331
- var path = _ref2.path,
1332
- _id = _ref2._id;
1333
-
1334
- var prev_url_to_check = prevUrl;
1335
- if (prev_url_to_check.includes('?')) {
1336
- prev_url_to_check = prev_url_to_check.split('?')[0];
1337
- }
1338
- if (prev_url_to_check.endsWith(path)) taxonomy.push(_id);
1339
- });
1340
-
1341
- if (taxonomy.length === 0) {
1342
- taxonomy = taxonomyMapping.map(function (_ref3) {
1343
- var _ref = _ref3._ref;
1344
- return _ref;
1345
- });
1346
- }
1347
-
1348
- var params = {
1349
- url: url,
1350
- taxonomy: taxonomy,
1351
- index: 0
1352
- };
1353
-
1354
- return React__default.createElement(ArticleQueue, _extends((_extends2 = {
1355
- client: client,
1356
- params: params,
1357
- relatedArticleQuery: relatedArticleQuery,
1358
- website: Website,
1359
- checkSponsered: true,
1360
- pageview: pageview,
1361
- shareOptions: shareOptions,
1362
- Ads: WAds,
1363
- regionalPages: regionalPages,
1364
- nationalPage: nationalPage
1365
- }, _defineProperty(_extends2, 'pageview', pageview), _defineProperty(_extends2, 'onVote', function onVote() {}), _defineProperty(_extends2, 'ISIContent', ISIContent), _defineProperty(_extends2, 'videoAccountIDs', videoAccountIDs), _defineProperty(_extends2, 'sponsoredTaxonomies', []), _defineProperty(_extends2, 'cpModificationRequired', cpModificationRequired), _defineProperty(_extends2, 'Settings', Settings), _defineProperty(_extends2, 'canonicalTag', canonicalTag), _extends2), props));
1366
- };
1367
-
1368
1325
  var _this$1 = undefined;
1369
1326
 
1370
1327
  var View = function View(props) {
@@ -1543,7 +1500,15 @@ var View = function View(props) {
1543
1500
  props.article.seriesDetail && props.article.seriesDetail.nextUrl && React__default.createElement('link', { rel: 'next', href: props.article.seriesDetail.nextUrl })
1544
1501
  )
1545
1502
  ),
1546
- !needInfiniteScroll ? React__default.createElement(Article, _extends({ infiniteScroll: false, showRelatedArticles: showRelatedArticles }, props)) : React__default.createElement(Articles, _extends({ infiniteScroll: true, showRelatedArticles: showRelatedArticles, canonicalTag: canonicalTag }, props))
1503
+ !needInfiniteScroll ? React__default.createElement(Article, _extends({ infiniteScroll: false, showRelatedArticles: showRelatedArticles }, props)) : React__default.createElement(ArticleQueue, _extends({
1504
+ infiniteScroll: true,
1505
+ showRelatedArticles: showRelatedArticles,
1506
+ canonicalTag: canonicalTag,
1507
+ checkSponsered: true,
1508
+ Ads: props.WAds,
1509
+ onVote: function onVote() {},
1510
+ sponsoredTaxonomies: []
1511
+ }, props))
1547
1512
  );
1548
1513
  };
1549
1514
 
@@ -8,9 +8,9 @@ var getQuery = function getQuery(type) {
8
8
 
9
9
  switch (type) {
10
10
  case 'related':
11
- 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 }';
11
+ 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 }';
12
12
  case 'article':
13
- 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 }';
13
+ 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 issueGroup-> { _id, name, identifier, parent-> },\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 }';
14
14
  case 'publication':
15
15
  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 }';
16
16
  case 'issue':
@@ -424,28 +424,33 @@ var dist_3 = dist.parseCookies;
424
424
  var _this = undefined;
425
425
 
426
426
  var getRelatedArticle = function () {
427
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
427
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
428
428
  var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
429
429
  var client = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
430
430
  var article = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
431
431
  var prevUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';
432
432
  var articleCount = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
433
433
 
434
- var taxonomyMapping, _article$url, url, content_placement, taxonomy, params, conditions, cookies, prevSlugs, relatedArticleQuery, relatedArticle;
434
+ var _article$url, url, documentGroupMapping, issueGroup, content_placement, references, params, articles, filters, cookies, prevSlugs, query;
435
435
 
436
436
  return regenerator.wrap(function _callee$(_context) {
437
437
  while (1) {
438
438
  switch (_context.prev = _context.next) {
439
439
  case 0:
440
- taxonomyMapping = article.taxonomyMapping, _article$url = article.url;
440
+ _article$url = article.url;
441
441
  _article$url = _article$url === undefined ? {
442
442
  current: null
443
443
  } : _article$url;
444
- url = _article$url.current, content_placement = article.content_placement;
445
- taxonomy = [];
446
- //404 articles were throwing server error
444
+ url = _article$url.current, documentGroupMapping = article.documentGroupMapping, issueGroup = article.issueGroup;
445
+ content_placement = article.content_placement;
446
+ references = [];
447
447
 
448
- if (content_placement) {
448
+
449
+ content_placement = content_placement && content_placement.length > 0 && content_placement.filter(function (_ref2) {
450
+ var identifier = _ref2.identifier;
451
+ return identifier !== 'news';
452
+ });
453
+ if (content_placement && content_placement.length > 0) {
449
454
  content_placement.forEach(function (_ref3) {
450
455
  var path = _ref3.path,
451
456
  _id = _ref3._id;
@@ -457,27 +462,39 @@ var getRelatedArticle = function () {
457
462
  if (prev_url_to_check.includes('?')) {
458
463
  prev_url_to_check = prev_url_to_check.split('?')[0];
459
464
  }
460
- if (prev_url_to_check.endsWith(path) && _id) taxonomy.push(_id);
465
+ if (prev_url_to_check.endsWith(path) && _id) references.push(_id);
461
466
  });
467
+ if (references.length === 0) {
468
+ content_placement.forEach(function (_ref4) {
469
+ var _id = _ref4._id;
470
+
471
+ if (_id) references.push(_id);
472
+ });
473
+ }
462
474
  }
463
475
 
464
- //404 articles were throwing server error
465
- if (taxonomy.length === 0 && taxonomyMapping) {
466
- taxonomyMapping.forEach(function (_ref4) {
467
- var _ref = _ref4._ref;
476
+ if (documentGroupMapping && documentGroupMapping.length > 0) {
477
+ documentGroupMapping.forEach(function (_ref5) {
478
+ var _id = _ref5._id;
468
479
 
469
- if (_ref) {
470
- taxonomy.push(_ref);
471
- }
480
+ if (_id) references.push(_id);
472
481
  });
473
482
  }
474
483
 
475
- params = {
476
- url: url,
477
- taxonomy: taxonomy,
478
- index: articleCount
479
- };
480
- conditions = '';
484
+ if (issueGroup && issueGroup._id) {
485
+ references.push(issueGroup._id);
486
+ }
487
+
488
+ params = { url: url, index: articleCount };
489
+ articles = null;
490
+
491
+ if (!(references && references.length > 0)) {
492
+ _context.next = 24;
493
+ break;
494
+ }
495
+
496
+ filters = '&& references("' + references.join('","') + '") ';
497
+
481
498
 
482
499
  if (ctx && url) {
483
500
  cookies = dist_3(ctx);
@@ -485,27 +502,39 @@ var getRelatedArticle = function () {
485
502
 
486
503
  if (!!prevSlugs) {
487
504
  dist_2(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"', {});
488
- conditions = '&& !(url.current in [' + prevSlugs + '])';
505
+ filters = '&& !(url.current in [' + prevSlugs + '])';
489
506
  } else dist_2(ctx, 'prevSlugs', '"' + url + '"', {});
490
507
  }
491
- relatedArticleQuery = getQuery('related', conditions, '', articleCount);
492
- _context.next = 12;
493
- return client.fetch(relatedArticleQuery, params);
494
508
 
495
- case 12:
496
- relatedArticle = _context.sent;
497
- return _context.abrupt('return', relatedArticle);
509
+ query = getQuery('related', filters, '', articleCount).replace('&& taxonomyMapping[]._ref in $taxonomy', '');
510
+ _context.prev = 15;
511
+ _context.next = 18;
512
+ return client.fetch(query, params);
513
+
514
+ case 18:
515
+ articles = _context.sent;
516
+ _context.next = 24;
517
+ break;
518
+
519
+ case 21:
520
+ _context.prev = 21;
521
+ _context.t0 = _context['catch'](15);
522
+
523
+ console.error(_context.t0);
524
+
525
+ case 24:
526
+ return _context.abrupt('return', articles);
498
527
 
499
- case 14:
528
+ case 25:
500
529
  case 'end':
501
530
  return _context.stop();
502
531
  }
503
532
  }
504
- }, _callee, _this);
533
+ }, _callee, _this, [[15, 21]]);
505
534
  }));
506
535
 
507
536
  return function getRelatedArticle() {
508
- return _ref2.apply(this, arguments);
537
+ return _ref.apply(this, arguments);
509
538
  };
510
539
  }();
511
540
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.700",
3
+ "version": "1.0.701",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",