@mjhls/mjh-framework 1.0.501 → 1.0.503

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.501
2
+ # mjh-framework v. 1.0.503
3
3
 
4
4
  > Foundation Framework
5
5
 
@@ -616,12 +616,12 @@ var Article = function Article(props) {
616
616
  React__default.createElement(
617
617
  'noscript',
618
618
  null,
619
- props.relatedArticle && props.relatedArticle.url && props.relatedArticle.url.current && React__default.createElement(
619
+ props.article.relatedArticle && props.article.relatedArticle.url && props.article.relatedArticle.url.current && React__default.createElement(
620
620
  'div',
621
621
  { style: { textAlign: 'center' } },
622
622
  React__default.createElement(
623
623
  'a',
624
- { href: '/view/' + props.relatedArticle.url.current },
624
+ { href: '/view/' + props.article.relatedArticle.url.current },
625
625
  'Related Article >>>'
626
626
  )
627
627
  )
package/dist/cjs/View.js CHANGED
@@ -57,9 +57,9 @@ var Dropdown = _interopDefault(require('react-bootstrap/Dropdown'));
57
57
  var InscreenSensor = require('./InscreenSensor-f9989c04.js');
58
58
  var getKeywords = require('./getKeywords.js');
59
59
  var getSeriesDetail = require('./getSeriesDetail.js');
60
+ var getQuery = require('./getQuery.js');
60
61
  var getTargeting = require('./getTargeting-86e68d62.js');
61
62
  var urlFor = require('./urlFor.js');
62
- var getQuery = require('./getQuery.js');
63
63
 
64
64
  var renderAuthor = function renderAuthor(authorName, authorURL, index, length) {
65
65
  var defaultUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'authors';
@@ -837,12 +837,12 @@ var Article = function Article(props) {
837
837
  React__default.createElement(
838
838
  'noscript',
839
839
  null,
840
- props.infiniteScroll && props.relatedArticle && props.relatedArticle.url && props.relatedArticle.url.current && React__default.createElement(
840
+ props.infiniteScroll && props.article.relatedArticle && props.article.relatedArticle.url && props.article.relatedArticle.url.current && React__default.createElement(
841
841
  'div',
842
842
  { style: { textAlign: 'center' } },
843
843
  React__default.createElement(
844
844
  'a',
845
- { href: '/view/' + props.relatedArticle.url.current },
845
+ { href: '/view/' + props.article.relatedArticle.url.current },
846
846
  'Related Article >>>'
847
847
  )
848
848
  )
@@ -20,7 +20,7 @@ var getQuery = function getQuery(type) {
20
20
  case 'issue':
21
21
  return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issue\': *[_type == \'publication\'\n && references(^._id)\n && identifier.current == $issue][0] {\n ...,\n \'articles\': *[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && is_visible\n && defined(url)\n && dateTime(published) <= dateTime($currentDate)\n && references(^._id)] {\n ...,\n authorMapping[0]->,\n contentCategory->,\n issueSection-> {\n name\n }\n }\n }\n }';
22
22
  case 'externalResources':
23
- return '{\n \'archived\': *[_type == "external" && archived && isVisible ' + conditions + '],\n \'recent\': *[_type == "external" && !archived && isVisible ' + conditions + ']\n }';
23
+ return '{\n \'archived\': *[_type == "external" && archived && isVisible ' + conditions + '] | order(displayDate desc),\n \'recent\': *[_type == "external" && !archived && isVisible ' + conditions + '] | order(displayDate desc)\n }';
24
24
  }
25
25
  };
26
26
 
@@ -0,0 +1,93 @@
1
+ 'use strict';
2
+
3
+ require('./_commonjsHelpers-06173234.js');
4
+ require('./_to-object-329a650b.js');
5
+ require('./core.get-iterator-method-41e87ec1.js');
6
+ require('./_library-dd23b178.js');
7
+ require('./_iter-detect-4d0352f8.js');
8
+ require('./web.dom.iterable-43c3e277.js');
9
+ require('./moment-3cf060f6.js');
10
+ var asyncToGenerator = require('./asyncToGenerator-8e707718.js');
11
+ require('./_set-species-4458e975.js');
12
+ var nookies = require('nookies');
13
+ var getQuery = require('./getQuery.js');
14
+
15
+ var _this = undefined;
16
+
17
+ var getRelatedArticle = function () {
18
+ var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
19
+ var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
20
+ var client = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
21
+ var article = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
22
+ var prevUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';
23
+
24
+ var taxonomyMapping, _article$url, url, content_placement, taxonomy, params, conditions, cookies, prevSlugs, relatedArticleQuery, relatedArticle;
25
+
26
+ return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
27
+ while (1) {
28
+ switch (_context.prev = _context.next) {
29
+ case 0:
30
+ taxonomyMapping = article.taxonomyMapping, _article$url = article.url;
31
+ _article$url = _article$url === undefined ? {
32
+ current: null
33
+ } : _article$url;
34
+ url = _article$url.current, content_placement = article.content_placement;
35
+ taxonomy = [];
36
+
37
+ content_placement.forEach(function (_ref3) {
38
+ var path = _ref3.path,
39
+ _id = _ref3._id;
40
+
41
+ var prev_url_to_check = prevUrl;
42
+ if (prev_url_to_check.includes('?')) {
43
+ prev_url_to_check = prev_url_to_check.split('?')[0];
44
+ }
45
+ if (prev_url_to_check.endsWith(path)) taxonomy.push(_id);
46
+ });
47
+
48
+ if (taxonomy.length === 0) {
49
+ taxonomy = taxonomyMapping.map(function (_ref4) {
50
+ var _ref = _ref4._ref;
51
+ return _ref;
52
+ });
53
+ }
54
+
55
+ params = {
56
+ url: url,
57
+ taxonomy: taxonomy,
58
+ index: 0
59
+ };
60
+ conditions = '';
61
+
62
+ if (ctx && url) {
63
+ cookies = nookies.parseCookies(ctx);
64
+ prevSlugs = cookies['prevSlugs'];
65
+
66
+ if (!!prevSlugs) {
67
+ nookies.setCookie(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"');
68
+ conditions = '&& !(url.current in [' + prevSlugs + '])';
69
+ } else nookies.setCookie(ctx, 'prevSlugs', '"' + url + '"');
70
+ }
71
+
72
+ relatedArticleQuery = getQuery('related', conditions);
73
+ _context.next = 12;
74
+ return client.fetch(relatedArticleQuery, params);
75
+
76
+ case 12:
77
+ relatedArticle = _context.sent;
78
+ return _context.abrupt('return', relatedArticle);
79
+
80
+ case 14:
81
+ case 'end':
82
+ return _context.stop();
83
+ }
84
+ }
85
+ }, _callee, _this);
86
+ }));
87
+
88
+ return function getRelatedArticle() {
89
+ return _ref2.apply(this, arguments);
90
+ };
91
+ }();
92
+
93
+ module.exports = getRelatedArticle;
package/dist/cjs/index.js CHANGED
@@ -154,6 +154,9 @@ var ConferenceArticleCard = require('./ConferenceArticleCard.js');
154
154
  var KMTracker = require('./KMTracker.js');
155
155
  var getSeriesDetail = require('./getSeriesDetail.js');
156
156
  var SetCookie = require('./SetCookie.js');
157
+ require('nookies');
158
+ var getQuery = require('./getQuery.js');
159
+ var getRelatedArticle = require('./getRelatedArticle.js');
157
160
  var Auth = require('./Auth.js');
158
161
  require('swr');
159
162
  require('passport-local');
@@ -161,7 +164,6 @@ require('mysql');
161
164
  var View = require('./View.js');
162
165
  var getTargeting = require('./getTargeting-86e68d62.js');
163
166
  var urlFor = require('./urlFor.js');
164
- var getQuery = require('./getQuery.js');
165
167
  require('react-twitter-embed');
166
168
  var PartnerDetailListing = require('./PartnerDetailListing.js');
167
169
 
@@ -240,9 +242,10 @@ exports.ConferenceArticleCard = ConferenceArticleCard;
240
242
  exports.KMTracker = KMTracker;
241
243
  exports.getSeriesDetail = getSeriesDetail;
242
244
  exports.SetCookie = SetCookie;
245
+ exports.getQuery = getQuery;
246
+ exports.getRelatedArticle = getRelatedArticle;
243
247
  exports.Auth = Auth.default;
244
248
  exports.View = View;
245
249
  exports.getTargeting = getTargeting.getTargeting;
246
250
  exports.urlFor = urlFor;
247
- exports.getQuery = getQuery;
248
251
  exports.PartnerDetailListing = PartnerDetailListing;
@@ -611,12 +611,12 @@ var Article = function Article(props) {
611
611
  React__default.createElement(
612
612
  'noscript',
613
613
  null,
614
- props.relatedArticle && props.relatedArticle.url && props.relatedArticle.url.current && React__default.createElement(
614
+ props.article.relatedArticle && props.article.relatedArticle.url && props.article.relatedArticle.url.current && React__default.createElement(
615
615
  'div',
616
616
  { style: { textAlign: 'center' } },
617
617
  React__default.createElement(
618
618
  'a',
619
- { href: '/view/' + props.relatedArticle.url.current },
619
+ { href: '/view/' + props.article.relatedArticle.url.current },
620
620
  'Related Article >>>'
621
621
  )
622
622
  )
package/dist/esm/View.js CHANGED
@@ -52,9 +52,9 @@ import Dropdown from 'react-bootstrap/Dropdown';
52
52
  import { I as InscreenSensor, i as includes_1 } from './InscreenSensor-67905ed5.js';
53
53
  import getKeywords from './getKeywords.js';
54
54
  import getSeriesDetail from './getSeriesDetail.js';
55
+ import getQuery from './getQuery.js';
55
56
  import { a as getContentPlacementUrl, g as getTargeting } from './getTargeting-1f2c61e3.js';
56
57
  import urlFor from './urlFor.js';
57
- import getQuery from './getQuery.js';
58
58
 
59
59
  var renderAuthor = function renderAuthor(authorName, authorURL, index, length) {
60
60
  var defaultUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'authors';
@@ -832,12 +832,12 @@ var Article = function Article(props) {
832
832
  React__default.createElement(
833
833
  'noscript',
834
834
  null,
835
- props.infiniteScroll && props.relatedArticle && props.relatedArticle.url && props.relatedArticle.url.current && React__default.createElement(
835
+ props.infiniteScroll && props.article.relatedArticle && props.article.relatedArticle.url && props.article.relatedArticle.url.current && React__default.createElement(
836
836
  'div',
837
837
  { style: { textAlign: 'center' } },
838
838
  React__default.createElement(
839
839
  'a',
840
- { href: '/view/' + props.relatedArticle.url.current },
840
+ { href: '/view/' + props.article.relatedArticle.url.current },
841
841
  'Related Article >>>'
842
842
  )
843
843
  )
@@ -18,7 +18,7 @@ var getQuery = function getQuery(type) {
18
18
  case 'issue':
19
19
  return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issue\': *[_type == \'publication\'\n && references(^._id)\n && identifier.current == $issue][0] {\n ...,\n \'articles\': *[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && is_visible\n && defined(url)\n && dateTime(published) <= dateTime($currentDate)\n && references(^._id)] {\n ...,\n authorMapping[0]->,\n contentCategory->,\n issueSection-> {\n name\n }\n }\n }\n }';
20
20
  case 'externalResources':
21
- return '{\n \'archived\': *[_type == "external" && archived && isVisible ' + conditions + '],\n \'recent\': *[_type == "external" && !archived && isVisible ' + conditions + ']\n }';
21
+ return '{\n \'archived\': *[_type == "external" && archived && isVisible ' + conditions + '] | order(displayDate desc),\n \'recent\': *[_type == "external" && !archived && isVisible ' + conditions + '] | order(displayDate desc)\n }';
22
22
  }
23
23
  };
24
24
 
@@ -0,0 +1,91 @@
1
+ import './_commonjsHelpers-0c4b6f40.js';
2
+ import './_to-object-16fd8b46.js';
3
+ import './core.get-iterator-method-f5c0d66a.js';
4
+ import './_library-528f1934.js';
5
+ import './_iter-detect-6e099a34.js';
6
+ import './web.dom.iterable-46c95e52.js';
7
+ import './moment-49ae13fa.js';
8
+ import { a as _asyncToGenerator, r as regenerator } from './asyncToGenerator-0379e924.js';
9
+ import './_set-species-6f64f1c1.js';
10
+ import { parseCookies, setCookie } from 'nookies';
11
+ import getQuery from './getQuery.js';
12
+
13
+ var _this = undefined;
14
+
15
+ var getRelatedArticle = function () {
16
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
17
+ var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
18
+ var client = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
19
+ var article = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
20
+ var prevUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';
21
+
22
+ var taxonomyMapping, _article$url, url, content_placement, taxonomy, params, conditions, cookies, prevSlugs, relatedArticleQuery, relatedArticle;
23
+
24
+ return regenerator.wrap(function _callee$(_context) {
25
+ while (1) {
26
+ switch (_context.prev = _context.next) {
27
+ case 0:
28
+ taxonomyMapping = article.taxonomyMapping, _article$url = article.url;
29
+ _article$url = _article$url === undefined ? {
30
+ current: null
31
+ } : _article$url;
32
+ url = _article$url.current, content_placement = article.content_placement;
33
+ taxonomy = [];
34
+
35
+ content_placement.forEach(function (_ref3) {
36
+ var path = _ref3.path,
37
+ _id = _ref3._id;
38
+
39
+ var prev_url_to_check = prevUrl;
40
+ if (prev_url_to_check.includes('?')) {
41
+ prev_url_to_check = prev_url_to_check.split('?')[0];
42
+ }
43
+ if (prev_url_to_check.endsWith(path)) taxonomy.push(_id);
44
+ });
45
+
46
+ if (taxonomy.length === 0) {
47
+ taxonomy = taxonomyMapping.map(function (_ref4) {
48
+ var _ref = _ref4._ref;
49
+ return _ref;
50
+ });
51
+ }
52
+
53
+ params = {
54
+ url: url,
55
+ taxonomy: taxonomy,
56
+ index: 0
57
+ };
58
+ conditions = '';
59
+
60
+ if (ctx && url) {
61
+ cookies = parseCookies(ctx);
62
+ prevSlugs = cookies['prevSlugs'];
63
+
64
+ if (!!prevSlugs) {
65
+ setCookie(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"');
66
+ conditions = '&& !(url.current in [' + prevSlugs + '])';
67
+ } else setCookie(ctx, 'prevSlugs', '"' + url + '"');
68
+ }
69
+
70
+ relatedArticleQuery = getQuery('related', conditions);
71
+ _context.next = 12;
72
+ return client.fetch(relatedArticleQuery, params);
73
+
74
+ case 12:
75
+ relatedArticle = _context.sent;
76
+ return _context.abrupt('return', relatedArticle);
77
+
78
+ case 14:
79
+ case 'end':
80
+ return _context.stop();
81
+ }
82
+ }
83
+ }, _callee, _this);
84
+ }));
85
+
86
+ return function getRelatedArticle() {
87
+ return _ref2.apply(this, arguments);
88
+ };
89
+ }();
90
+
91
+ export default getRelatedArticle;
package/dist/esm/index.js CHANGED
@@ -150,6 +150,9 @@ export { default as ConferenceArticleCard } from './ConferenceArticleCard.js';
150
150
  export { default as KMTracker } from './KMTracker.js';
151
151
  export { default as getSeriesDetail } from './getSeriesDetail.js';
152
152
  export { default as SetCookie } from './SetCookie.js';
153
+ import 'nookies';
154
+ export { default as getQuery } from './getQuery.js';
155
+ export { default as getRelatedArticle } from './getRelatedArticle.js';
153
156
  export { default as Auth } from './Auth.js';
154
157
  import 'swr';
155
158
  import 'passport-local';
@@ -157,6 +160,5 @@ import 'mysql';
157
160
  export { default as View } from './View.js';
158
161
  export { g as getTargeting } from './getTargeting-1f2c61e3.js';
159
162
  export { default as urlFor } from './urlFor.js';
160
- export { default as getQuery } from './getQuery.js';
161
163
  import 'react-twitter-embed';
162
164
  export { default as PartnerDetailListing } from './PartnerDetailListing.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.501",
3
+ "version": "1.0.503",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",
@@ -96,6 +96,7 @@
96
96
  "cookie": "^0.4.1",
97
97
  "js-cookie": "^2.2.1",
98
98
  "next-cookies": "^2.0.3",
99
+ "nookies": "^2.4.0",
99
100
  "react-cookies": "^0.1.1",
100
101
  "react-twitter-embed": "^3.0.3",
101
102
  "shortid": "^2.2.15",