hexo-component-inferno 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/lib/core/migrate.js +10 -28
  2. package/lib/core/migrate.test.js +10 -12
  3. package/lib/core/schema.js +33 -109
  4. package/lib/core/schema.test.js +2 -6
  5. package/lib/core/view.js +3 -10
  6. package/lib/core/view.test.js +0 -7
  7. package/lib/hexo/filter/locals.js +3 -18
  8. package/lib/hexo/filter/locals.test.js +2 -19
  9. package/lib/hexo/generator/assets.js +2 -8
  10. package/lib/hexo/generator/assets.test.js +0 -4
  11. package/lib/hexo/generator/categories.test.js +0 -3
  12. package/lib/hexo/generator/category.js +1 -6
  13. package/lib/hexo/generator/category.test.js +0 -5
  14. package/lib/hexo/generator/insight.js +1 -9
  15. package/lib/hexo/generator/insight.test.js +0 -3
  16. package/lib/hexo/generator/manifest.js +0 -3
  17. package/lib/hexo/generator/manifest.test.js +0 -3
  18. package/lib/hexo/generator/tags.test.js +0 -3
  19. package/lib/hexo/helper/cdn.js +6 -19
  20. package/lib/hexo/helper/cdn.test.js +0 -3
  21. package/lib/hexo/helper/page.test.js +0 -3
  22. package/lib/hexo/tag/message.js +0 -8
  23. package/lib/hexo/tag/message.test.js +0 -7
  24. package/lib/hexo/tag/tabs.js +3 -35
  25. package/lib/hexo/tag/tabs.test.js +0 -8
  26. package/lib/util/cache.js +0 -11
  27. package/lib/util/cache.test.js +0 -4
  28. package/lib/util/classname.js +0 -3
  29. package/lib/util/classname.test.js +0 -1
  30. package/lib/util/yaml.js +2 -7
  31. package/lib/util/yaml.test.js +0 -4
  32. package/lib/view/comment/changyan.js +12 -31
  33. package/lib/view/comment/disqus.js +11 -32
  34. package/lib/view/comment/disqusjs.js +22 -43
  35. package/lib/view/comment/facebook.js +9 -28
  36. package/lib/view/comment/gitalk.js +28 -49
  37. package/lib/view/comment/gitment.js +15 -37
  38. package/lib/view/comment/isso.js +6 -27
  39. package/lib/view/comment/livere.js +6 -27
  40. package/lib/view/comment/twikoo.js +14 -33
  41. package/lib/view/comment/utterances.js +17 -45
  42. package/lib/view/comment/valine.js +39 -60
  43. package/lib/view/comment/waline.js +45 -66
  44. package/lib/view/common/article_media.js +11 -28
  45. package/lib/view/donate/afdian.js +9 -30
  46. package/lib/view/donate/alipay.js +9 -30
  47. package/lib/view/donate/buymeacoffee.js +9 -30
  48. package/lib/view/donate/patreon.js +9 -30
  49. package/lib/view/donate/paypal.js +10 -31
  50. package/lib/view/donate/wechat.js +9 -30
  51. package/lib/view/misc/article_licensing.js +21 -43
  52. package/lib/view/misc/meta.js +7 -34
  53. package/lib/view/misc/open_graph.js +25 -67
  54. package/lib/view/misc/paginator.js +12 -36
  55. package/lib/view/misc/structured_data.js +16 -43
  56. package/lib/view/misc/web_app.js +16 -50
  57. package/lib/view/plugin/baidu_analytics.js +7 -28
  58. package/lib/view/plugin/bing_webmaster.js +7 -28
  59. package/lib/view/plugin/busuanzi.js +6 -26
  60. package/lib/view/plugin/cnzz.js +9 -30
  61. package/lib/view/plugin/cookie_consent.js +28 -49
  62. package/lib/view/plugin/gallery.js +10 -31
  63. package/lib/view/plugin/google_analytics.js +7 -28
  64. package/lib/view/plugin/hotjar.js +7 -28
  65. package/lib/view/plugin/katex.js +11 -32
  66. package/lib/view/plugin/mathjax.js +7 -28
  67. package/lib/view/plugin/outdated_browser.js +10 -31
  68. package/lib/view/plugin/progressbar.js +7 -28
  69. package/lib/view/plugin/statcounter.js +10 -31
  70. package/lib/view/plugin/twitter_conversion_tracking.js +7 -28
  71. package/lib/view/search/algolia.js +14 -35
  72. package/lib/view/search/baidu.js +9 -28
  73. package/lib/view/search/google_cse.js +10 -30
  74. package/lib/view/search/insight.js +9 -28
  75. package/lib/view/share/addthis.js +6 -27
  76. package/lib/view/share/addtoany.js +6 -25
  77. package/lib/view/share/bdshare.js +6 -25
  78. package/lib/view/share/sharejs.js +8 -27
  79. package/lib/view/share/sharethis.js +6 -27
  80. package/lib/view/widget/adsense.js +11 -32
  81. package/lib/view/widget/archives.js +26 -52
  82. package/lib/view/widget/categories.js +25 -57
  83. package/lib/view/widget/followit.js +12 -31
  84. package/lib/view/widget/links.js +27 -39
  85. package/lib/view/widget/recent_posts.js +15 -36
  86. package/lib/view/widget/subscribe_email.js +12 -31
  87. package/lib/view/widget/tags.js +16 -39
  88. package/lib/view/widget/toc.js +27 -67
  89. package/package.json +1 -1
@@ -82,10 +82,8 @@ module.exports = function (hexo) {
82
82
  let i = 0;
83
83
  let state = 1;
84
84
  let begin = 0;
85
-
86
85
  while (i <= s.length) {
87
86
  const c = i < s.length ? s.charAt(i) : '';
88
-
89
87
  switch (state) {
90
88
  case 1:
91
89
  if (c === ' ') {
@@ -102,39 +100,30 @@ module.exports = function (hexo) {
102
100
  } else {
103
101
  state = 7;
104
102
  }
105
-
106
103
  break;
107
-
108
104
  case 2:
109
105
  if (c === '\\') {
110
106
  state = 3;
111
107
  } else if (c === '"') {
112
108
  state = 6;
113
109
  }
114
-
115
110
  break;
116
-
117
111
  case 3:
118
112
  state = 2;
119
113
  break;
120
-
121
114
  case 4:
122
115
  if (c === '\\') {
123
116
  state = 5;
124
117
  } else if (c === "'") {
125
118
  state = 6;
126
119
  }
127
-
128
120
  break;
129
-
130
121
  case 5:
131
122
  state = 4;
132
123
  break;
133
-
134
124
  case 6:
135
125
  options.push(s.substring(begin, i - 1));
136
126
  begin = i + 1;
137
-
138
127
  if (c === ' ') {
139
128
  state = 1;
140
129
  } else if (c === '') {
@@ -142,9 +131,7 @@ module.exports = function (hexo) {
142
131
  } else {
143
132
  throw new Error(`malformatted tab options: ${s}`);
144
133
  }
145
-
146
134
  break;
147
-
148
135
  case 7:
149
136
  if (c === ' ') {
150
137
  options.push(s.substring(begin, i));
@@ -155,81 +142,63 @@ module.exports = function (hexo) {
155
142
  begin = i + 1;
156
143
  state = EOL;
157
144
  }
158
-
159
145
  break;
160
146
  }
161
-
162
147
  i++;
163
148
  }
164
-
165
149
  if (state !== EOL) {
166
150
  throw new Error(`malformatted tab options: ${s}`);
167
151
  }
168
-
169
152
  return options;
170
153
  }
171
-
172
154
  function processTag(options, content) {
173
155
  let classes = '';
174
-
175
156
  for (const option of options) {
176
157
  const [key, value] = option.split(':');
177
-
178
158
  switch (key) {
179
159
  case 'align':
180
160
  classes += ` is-${value}`;
181
161
  break;
182
-
183
162
  case 'size':
184
163
  classes += ` is-${value}`;
185
164
  break;
186
-
187
165
  case 'style':
188
166
  if (value === 'toggle-rounded') {
189
167
  classes += ' is-toggle';
190
168
  }
191
-
192
169
  classes += ` is-${value}`;
193
170
  break;
194
171
  }
195
172
  }
196
-
197
173
  const pattern = /<!--\s*tab\s*(.*?)\s*-->([\s\S]*?)<!--\s*endtab\s*-->/g;
198
174
  let match;
199
175
  let tabElements = '';
200
176
  let contentElements = '';
201
-
202
177
  while ((match = pattern.exec(content)) !== null) {
203
178
  const [, tabOptions, tabContent] = match;
204
179
  let id = 'tab-' + Date.now() + (Math.random() * 1000 | 0);
205
180
  let icon = '';
206
181
  let title = '';
207
182
  let active = false;
208
-
209
183
  for (const option of splitTabOptions(tabOptions)) {
210
184
  const [key, value] = option.split(':');
211
-
212
185
  switch (key) {
213
186
  case 'id':
214
187
  id = value;
215
188
  break;
216
-
217
189
  case 'active':
218
190
  active = true;
219
191
  break;
220
-
221
192
  case 'icon':
222
193
  icon = `<span class="icon is-small ml-0">
223
194
  <i class="${value}" aria-hidden="true"></i>
224
195
  </span>`;
225
196
  break;
226
-
227
197
  case 'title':
228
198
  title = value;
229
199
  break;
230
200
  }
231
201
  }
232
-
233
202
  tabElements += `<li${active ? ' class="is-active"' : ''}>
234
203
  <a href="#${id}">
235
204
  ${hexo.render.renderSync({
@@ -245,7 +214,6 @@ module.exports = function (hexo) {
245
214
  })}
246
215
  </div>`;
247
216
  }
248
-
249
217
  return `<div class="tabs my-3${classes}">
250
218
  <ul class="mx-0 my-0">
251
219
  ${tabElements}
@@ -253,7 +221,6 @@ module.exports = function (hexo) {
253
221
  </div>
254
222
  ${contentElements}`;
255
223
  }
256
-
257
224
  const script = `<script>
258
225
  (function () {
259
226
  function switchTab() {
@@ -261,7 +228,8 @@ module.exports = function (hexo) {
261
228
  return;
262
229
  }
263
230
 
264
- const $tabMenu = document.querySelector(\`a[href="\${location.hash}"]\`);
231
+ const id = '#' + CSS.escape(location.hash.substring(1));
232
+ const $tabMenu = document.querySelector(\`.tabs a[href="\${id}"]\`);
265
233
  if (!$tabMenu) {
266
234
  return;
267
235
  }
@@ -275,7 +243,7 @@ module.exports = function (hexo) {
275
243
  if ($tabMenu) {
276
244
  $tabMenu.parentElement.classList.add('is-active');
277
245
  }
278
- const $activeTab = document.querySelector(location.hash);
246
+ const $activeTab = document.querySelector(id);
279
247
  if ($activeTab) {
280
248
  $activeTab.classList.remove('is-hidden');
281
249
  }
@@ -1,17 +1,12 @@
1
1
  const {
2
2
  join
3
3
  } = require('path');
4
-
5
4
  const Hexo = require('hexo');
6
-
7
5
  const {
8
6
  minify
9
7
  } = require('html-minifier');
10
-
11
8
  const cheerio = require('cheerio');
12
-
13
9
  const register = require('./tabs');
14
-
15
10
  const rootDir = join(__dirname, '../../../fixture/site');
16
11
  const hexo = new Hexo(rootDir, {
17
12
  silent: true
@@ -48,7 +43,6 @@ test('create default tabs', async () => {
48
43
  });
49
44
  test('create tabs with different alignment', async () => {
50
45
  const render = hexo.extend.tag.render.bind(hexo.extend.tag);
51
-
52
46
  for (const align of ['left', 'centered', 'right', 'fullwidth']) {
53
47
  const source = `{% tabs align:${align} %}<!--tab id:tab1-->content<!--endtab-->{% endtabs %}`;
54
48
  const actual = cheerio.load(await render(source), cheerioOptions, false).html();
@@ -57,7 +51,6 @@ test('create tabs with different alignment', async () => {
57
51
  });
58
52
  test('create tabs with different sizes', async () => {
59
53
  const render = hexo.extend.tag.render.bind(hexo.extend.tag);
60
-
61
54
  for (const size of ['small', 'medium', 'large']) {
62
55
  const source = `{% tabs size:${size} %}<!--tab id:tab1-->content<!--endtab-->{% endtabs %}`;
63
56
  const actual = cheerio.load(await render(source), cheerioOptions, false).html();
@@ -66,7 +59,6 @@ test('create tabs with different sizes', async () => {
66
59
  });
67
60
  test('create tabs with different styles', async () => {
68
61
  const render = hexo.extend.tag.render.bind(hexo.extend.tag);
69
-
70
62
  for (const style of ['boxed', 'toggle', 'toggle-rounded']) {
71
63
  const source = `{% tabs style:${style} %}<!--tab id:tab1-->content<!--endtab-->{% endtabs %}`;
72
64
  const actual = cheerio.load(await render(source), cheerioOptions, false).html();
package/lib/util/cache.js CHANGED
@@ -3,22 +3,16 @@
3
3
  * @module util/cache
4
4
  */
5
5
  const crypto = require('crypto');
6
-
7
6
  const {
8
7
  Component
9
8
  } = require('inferno'); // eslint-disable-line no-unused-vars
10
-
11
-
12
9
  const {
13
10
  createElement
14
11
  } = require('inferno-create-element');
15
-
16
12
  const cache = {};
17
-
18
13
  function computeHash(props) {
19
14
  return crypto.createHash('md5').update(JSON.stringify(props)).digest('hex');
20
15
  }
21
-
22
16
  module.exports = {
23
17
  /**
24
18
  * Create cached component from a given component class.
@@ -42,19 +36,14 @@ module.exports = {
42
36
  cacheComponent(type, prefix, transform) {
43
37
  return props => {
44
38
  const targetProps = transform(props);
45
-
46
39
  if (targetProps === null || typeof targetProps !== 'object') {
47
40
  return null;
48
41
  }
49
-
50
42
  const cacheId = prefix + '-' + computeHash(targetProps);
51
-
52
43
  if (!cache[cacheId]) {
53
44
  cache[cacheId] = createElement(type, targetProps);
54
45
  }
55
-
56
46
  return cache[cacheId];
57
47
  };
58
48
  }
59
-
60
49
  };
@@ -1,17 +1,13 @@
1
1
  const {
2
2
  renderToStaticMarkup
3
3
  } = require('inferno-server');
4
-
5
4
  const {
6
5
  createElement
7
6
  } = require('inferno-create-element');
8
-
9
7
  const {
10
8
  cacheComponent
11
9
  } = require('../util/cache');
12
-
13
10
  const Example = require('../../fixture/layout/example');
14
-
15
11
  test('The cached component can be successfully rendered', () => {
16
12
  const props = {
17
13
  subject: 'world'
@@ -16,14 +16,11 @@ module.exports = function (classname) {
16
16
  if (typeof classname === 'string') {
17
17
  return classname;
18
18
  }
19
-
20
19
  if (Array.isArray(classname)) {
21
20
  return classname.join(' ');
22
21
  }
23
-
24
22
  if (typeof classname === 'object') {
25
23
  return Object.keys(classname).filter(key => !!classname[key]).join(' ');
26
24
  }
27
-
28
25
  throw new Error('Cannot process class name ' + JSON.stringify(classname));
29
26
  };
@@ -1,5 +1,4 @@
1
1
  const classname = require('../util/classname');
2
-
3
2
  test('Correctly create the class name string', () => {
4
3
  expect(classname('class-1')).toBe('class-1');
5
4
  expect(classname(['class-1', 'class-2'])).toBe('class-1 class-2');
package/lib/util/yaml.js CHANGED
@@ -2,22 +2,19 @@
2
2
  * Custom YAML parse and stringify functions.
3
3
  * @module util/yaml
4
4
  */
5
- const yaml = require('js-yaml'); // output null as empty in yaml
6
-
5
+ const yaml = require('js-yaml');
7
6
 
7
+ // output null as empty in yaml
8
8
  const YAML_SCHEMA = yaml.DEFAULT_SCHEMA.extend({
9
9
  implicit: [new yaml.Type('tag:yaml.org,2002:null', {
10
10
  kind: 'scalar',
11
-
12
11
  resolve(data) {
13
12
  if (data === null) {
14
13
  return true;
15
14
  }
16
-
17
15
  const max = data.length;
18
16
  return max === 1 && data === '~' || max === 4 && (data === 'null' || data === 'Null' || data === 'NULL');
19
17
  },
20
-
21
18
  construct: () => null,
22
19
  predicate: object => object === null,
23
20
  represent: {
@@ -36,7 +33,6 @@ module.exports = {
36
33
  parse(str) {
37
34
  return yaml.load(str);
38
35
  },
39
-
40
36
  /**
41
37
  * Dump the YAML string of a JavaScript value.
42
38
  *
@@ -50,5 +46,4 @@ module.exports = {
50
46
  schema: YAML_SCHEMA
51
47
  });
52
48
  }
53
-
54
49
  };
@@ -1,9 +1,6 @@
1
1
  const fs = require('fs');
2
-
3
2
  const path = require('path');
4
-
5
3
  const yaml = require('../util/yaml');
6
-
7
4
  test('Correctly parse YAML string', () => {
8
5
  const example = fs.readFileSync(path.join(__dirname, '../../fixture/misc/original.yaml'), {
9
6
  encoding: 'utf8'
@@ -14,7 +11,6 @@ test('Correctly parse YAML string', () => {
14
11
  });
15
12
  test('Correctly format to YAML string', () => {
16
13
  const example = require('../../fixture/misc/parsed.json');
17
-
18
14
  const expected = fs.readFileSync(path.join(__dirname, '../../fixture/misc/stringified.yaml'), {
19
15
  encoding: 'utf8'
20
16
  });
@@ -1,38 +1,28 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  var _inferno = require("inferno");
6
-
7
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
-
9
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10
-
6
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
11
7
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
12
-
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
10
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
14
-
15
11
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
-
17
12
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18
-
19
13
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
20
-
21
14
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22
-
23
15
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
-
25
16
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
-
27
17
  /**
28
18
  * ChangYan comment JSX component.
29
19
  * @module view/comment/changyan
30
20
  */
31
21
  var _require = require('inferno'),
32
- Component = _require.Component;
33
-
22
+ Component = _require.Component;
34
23
  var _require2 = require('../../util/cache'),
35
- cacheComponent = _require2.cacheComponent;
24
+ cacheComponent = _require2.cacheComponent;
25
+
36
26
  /**
37
27
  * ChangYan comment JSX component.
38
28
  *
@@ -43,32 +33,25 @@ var _require2 = require('../../util/cache'),
43
33
  * conf="******"
44
34
  * path="/path/to/page" />
45
35
  */
46
-
47
-
48
36
  var ChangYan = /*#__PURE__*/function (_Component) {
49
37
  _inherits(ChangYan, _Component);
50
-
51
38
  var _super = _createSuper(ChangYan);
52
-
53
39
  function ChangYan() {
54
40
  _classCallCheck(this, ChangYan);
55
-
56
41
  return _super.apply(this, arguments);
57
42
  }
58
-
59
43
  _createClass(ChangYan, [{
60
44
  key: "render",
61
45
  value: function render() {
62
46
  var _this$props = this.props,
63
- appId = _this$props.appId,
64
- conf = _this$props.conf,
65
- path = _this$props.path;
66
-
47
+ appId = _this$props.appId,
48
+ conf = _this$props.conf,
49
+ path = _this$props.path;
67
50
  if (!appId || !conf) {
68
51
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "app_id", 16), (0, _inferno.createTextVNode)(" or "), (0, _inferno.createVNode)(1, "code", null, "conf", 16), (0, _inferno.createTextVNode)(" for Changyan. Please set it in "), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 4);
69
52
  }
70
-
71
53
  var js = "window.changyan.api.config({appid: '".concat(appId, "',conf: '").concat(conf, "'});");
54
+ /* eslint-disable react/no-unknown-property */
72
55
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, null, 1, {
73
56
  "id": "SOHUCS",
74
57
  "sid": path
@@ -80,9 +63,9 @@ var ChangYan = /*#__PURE__*/function (_Component) {
80
63
  __html: js
81
64
  }
82
65
  })], 4);
66
+ /* eslint-enable react/no-unknown-property */
83
67
  }
84
68
  }]);
85
-
86
69
  return ChangYan;
87
70
  }(Component);
88
71
  /**
@@ -97,11 +80,9 @@ var ChangYan = /*#__PURE__*/function (_Component) {
97
80
  * comment={{ app_id: '*******', conf='******' }}
98
81
  * page={{ path: '/path/to/page' }} />
99
82
  */
100
-
101
-
102
83
  ChangYan.Cacheable = cacheComponent(ChangYan, 'comment.changyan', function (props) {
103
84
  var comment = props.comment,
104
- page = props.page;
85
+ page = props.page;
105
86
  return {
106
87
  appId: comment.app_id,
107
88
  conf: comment.conf,
@@ -1,38 +1,28 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  var _inferno = require("inferno");
6
-
7
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
-
9
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10
-
6
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
11
7
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
12
-
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
10
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
14
-
15
11
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
-
17
12
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18
-
19
13
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
20
-
21
14
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22
-
23
15
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
-
25
16
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
-
27
17
  /**
28
18
  * Disqus comment JSX component.
29
19
  * @module view/comment/disqus
30
20
  */
31
21
  var _require = require('inferno'),
32
- Component = _require.Component;
33
-
22
+ Component = _require.Component;
34
23
  var _require2 = require('../../util/cache'),
35
- cacheComponent = _require2.cacheComponent;
24
+ cacheComponent = _require2.cacheComponent;
25
+
36
26
  /**
37
27
  * Disqus comment JSX component.
38
28
  *
@@ -44,32 +34,24 @@ var _require2 = require('../../util/cache'),
44
34
  * permalink="/page/permanent/path"
45
35
  * path="/path/to/page" />
46
36
  */
47
-
48
-
49
37
  var Disqus = /*#__PURE__*/function (_Component) {
50
38
  _inherits(Disqus, _Component);
51
-
52
39
  var _super = _createSuper(Disqus);
53
-
54
40
  function Disqus() {
55
41
  _classCallCheck(this, Disqus);
56
-
57
42
  return _super.apply(this, arguments);
58
43
  }
59
-
60
44
  _createClass(Disqus, [{
61
45
  key: "render",
62
46
  value: function render() {
63
47
  var _this$props = this.props,
64
- shortname = _this$props.shortname,
65
- disqusId = _this$props.disqusId,
66
- path = _this$props.path,
67
- permalink = _this$props.permalink;
68
-
48
+ shortname = _this$props.shortname,
49
+ disqusId = _this$props.disqusId,
50
+ path = _this$props.path,
51
+ permalink = _this$props.permalink;
69
52
  if (!shortname) {
70
53
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "shortname", 16), (0, _inferno.createTextVNode)(" for Disqus. Please set it in"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
71
54
  }
72
-
73
55
  var js = "var disqus_config = function () {\n this.page.url = '".concat(permalink, "';\n this.page.identifier = '").concat(disqusId || path, "';\n };\n (function() {\n var d = document, s = d.createElement('script'); \n s.src = '//' + '").concat(shortname, "' + '.disqus.com/embed.js';\n s.setAttribute('data-timestamp', +new Date());\n (d.head || d.body).appendChild(s);\n })();");
74
56
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, (0, _inferno.createVNode)(1, "noscript", null, [(0, _inferno.createTextVNode)("Please enable JavaScript to view the"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "a", null, "comments powered by Disqus.", 16, {
75
57
  "href": "//disqus.com/?ref_noscript"
@@ -82,7 +64,6 @@ var Disqus = /*#__PURE__*/function (_Component) {
82
64
  })], 4);
83
65
  }
84
66
  }]);
85
-
86
67
  return Disqus;
87
68
  }(Component);
88
69
  /**
@@ -101,11 +82,9 @@ var Disqus = /*#__PURE__*/function (_Component) {
101
82
  * permalink: '/page/permanent/link'
102
83
  * }} />
103
84
  */
104
-
105
-
106
85
  Disqus.Cacheable = cacheComponent(Disqus, 'comment.disqus', function (props) {
107
86
  var comment = props.comment,
108
- page = props.page;
87
+ page = props.page;
109
88
  return {
110
89
  path: page.path,
111
90
  shortname: comment.shortname,