@mjhls/mjh-framework 1.0.699 → 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.
@@ -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.699",
3
+ "version": "1.0.701",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",