hexo-component-inferno 2.0.0 → 2.0.2

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 +17 -48
  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 +15 -49
  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 +24 -51
  82. package/lib/view/widget/categories.js +23 -57
  83. package/lib/view/widget/followit.js +12 -31
  84. package/lib/view/widget/links.js +10 -32
  85. package/lib/view/widget/recent_posts.js +14 -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 +26 -66
  89. package/package.json +1 -1
@@ -1,48 +1,34 @@
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
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
28
-
29
18
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
30
-
31
19
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
32
-
33
20
  /**
34
21
  * Table of contents widget JSX component.
35
22
  * @module view/widget/toc
36
23
  */
37
24
  var _require = require('hexo-util'),
38
- getTocObj = _require.tocObj,
39
- unescapeHTML = _require.unescapeHTML;
40
-
25
+ getTocObj = _require.tocObj,
26
+ unescapeHTML = _require.unescapeHTML;
41
27
  var _require2 = require('inferno'),
42
- Component = _require2.Component;
43
-
28
+ Component = _require2.Component;
44
29
  var _require3 = require('../../util/cache'),
45
- cacheComponent = _require3.cacheComponent;
30
+ cacheComponent = _require3.cacheComponent;
31
+
46
32
  /**
47
33
  * Export a tree of headings of an article
48
34
  * @private
@@ -76,8 +62,6 @@ var _require3 = require('../../util/cache'),
76
62
  * // }
77
63
  * // }
78
64
  */
79
-
80
-
81
65
  function getToc(content, maxDepth) {
82
66
  var toc = {};
83
67
  var tocObj = getTocObj(content, {
@@ -94,11 +78,9 @@ function getToc(content, maxDepth) {
94
78
  if (!minLevels.includes(item.level)) {
95
79
  return;
96
80
  }
97
-
98
81
  var text = item.text,
99
- id = item.id;
82
+ id = item.id;
100
83
  var level = item.level - minLevels[0];
101
-
102
84
  for (var i = 0; i < levels.length; i++) {
103
85
  if (i > level) {
104
86
  levels[i] = 0;
@@ -112,20 +94,15 @@ function getToc(content, maxDepth) {
112
94
  levels[i] += 1;
113
95
  }
114
96
  }
115
-
116
97
  var node = toc;
117
-
118
98
  var _iterator = _createForOfIteratorHelper(levels.slice(0, level + 1)),
119
- _step;
120
-
99
+ _step;
121
100
  try {
122
101
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
123
102
  var _i = _step.value;
124
-
125
103
  if (!(_i in node)) {
126
104
  node[_i] = {};
127
105
  }
128
-
129
106
  node = node[_i];
130
107
  }
131
108
  } catch (err) {
@@ -133,13 +110,13 @@ function getToc(content, maxDepth) {
133
110
  } finally {
134
111
  _iterator.f();
135
112
  }
136
-
137
113
  node.id = id;
138
114
  node.text = text;
139
115
  node.index = levels.slice(0, level + 1).join('.');
140
116
  });
141
117
  return toc;
142
118
  }
119
+
143
120
  /**
144
121
  * Table of contents widget JSX component.
145
122
  *
@@ -152,24 +129,17 @@ function getToc(content, maxDepth) {
152
129
  * maxDepth={3}
153
130
  * jsUrl="******" />
154
131
  */
155
-
156
-
157
132
  var Toc = /*#__PURE__*/function (_Component) {
158
133
  _inherits(Toc, _Component);
159
-
160
134
  var _super = _createSuper(Toc);
161
-
162
135
  function Toc() {
163
136
  _classCallCheck(this, Toc);
164
-
165
137
  return _super.apply(this, arguments);
166
138
  }
167
-
168
139
  _createClass(Toc, [{
169
140
  key: "renderToc",
170
141
  value: function renderToc(toc) {
171
142
  var _this = this;
172
-
173
143
  var showIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
174
144
  var result;
175
145
  var keys = Object.keys(toc).filter(function (key) {
@@ -179,36 +149,31 @@ var Toc = /*#__PURE__*/function (_Component) {
179
149
  }).sort(function (a, b) {
180
150
  return a - b;
181
151
  });
182
-
183
152
  if (keys.length > 0) {
184
153
  result = (0, _inferno.createVNode)(1, "ul", "menu-list", keys.map(function (i) {
185
154
  return _this.renderToc(toc[i], showIndex);
186
155
  }), 0);
187
156
  }
188
-
189
157
  if ('id' in toc && 'index' in toc && 'text' in toc) {
190
158
  result = (0, _inferno.createVNode)(1, "li", null, [(0, _inferno.createVNode)(1, "a", "level is-mobile", (0, _inferno.createVNode)(1, "span", "level-left", [showIndex ? (0, _inferno.createVNode)(1, "span", "level-item", toc.index, 0) : null, (0, _inferno.createVNode)(1, "span", "level-item", unescapeHTML(toc.text), 0)], 0), 2, {
191
159
  "href": '#' + toc.id
192
160
  }), result], 0);
193
161
  }
194
-
195
162
  return result;
196
163
  }
197
164
  }, {
198
165
  key: "render",
199
166
  value: function render() {
200
167
  var _this$props = this.props,
201
- showIndex = _this$props.showIndex,
202
- _this$props$maxDepth = _this$props.maxDepth,
203
- maxDepth = _this$props$maxDepth === void 0 ? 3 : _this$props$maxDepth,
204
- _this$props$collapsed = _this$props.collapsed,
205
- collapsed = _this$props$collapsed === void 0 ? true : _this$props$collapsed;
168
+ showIndex = _this$props.showIndex,
169
+ _this$props$maxDepth = _this$props.maxDepth,
170
+ maxDepth = _this$props$maxDepth === void 0 ? 3 : _this$props$maxDepth,
171
+ _this$props$collapsed = _this$props.collapsed,
172
+ collapsed = _this$props$collapsed === void 0 ? true : _this$props$collapsed;
206
173
  var toc = getToc(this.props.content, maxDepth);
207
-
208
174
  if (!Object.keys(toc).length) {
209
175
  return null;
210
176
  }
211
-
212
177
  var css = '#toc .menu-list > li > a.is-active + .menu-list { display: block; }' + '#toc .menu-list > li > a + .menu-list { display: none; }';
213
178
  return (0, _inferno.createVNode)(1, "div", "card widget", [(0, _inferno.createVNode)(1, "div", "card-content", (0, _inferno.createVNode)(1, "div", "menu", [(0, _inferno.createVNode)(1, "h3", "menu-label", this.props.title, 0), this.renderToc(toc, showIndex)], 0), 2), collapsed ? (0, _inferno.createVNode)(1, "style", null, null, 1, {
214
179
  "dangerouslySetInnerHTML": {
@@ -223,7 +188,6 @@ var Toc = /*#__PURE__*/function (_Component) {
223
188
  });
224
189
  }
225
190
  }]);
226
-
227
191
  return Toc;
228
192
  }(Component);
229
193
  /**
@@ -243,27 +207,23 @@ var Toc = /*#__PURE__*/function (_Component) {
243
207
  * url_for: function() {...}
244
208
  * }} /> />
245
209
  */
246
-
247
-
248
210
  Toc.Cacheable = cacheComponent(Toc, 'widget.toc', function (props) {
249
211
  var config = props.config,
250
- page = props.page,
251
- widget = props.widget,
252
- helper = props.helper;
212
+ page = props.page,
213
+ widget = props.widget,
214
+ helper = props.helper;
253
215
  var layout = page.layout,
254
- content = page.content,
255
- encrypt = page.encrypt,
256
- origin = page.origin;
216
+ content = page.content,
217
+ encrypt = page.encrypt,
218
+ origin = page.origin;
257
219
  var index = widget.index,
258
- _widget$collapsed = widget.collapsed,
259
- collapsed = _widget$collapsed === void 0 ? true : _widget$collapsed,
260
- _widget$depth = widget.depth,
261
- depth = _widget$depth === void 0 ? 3 : _widget$depth;
262
-
220
+ _widget$collapsed = widget.collapsed,
221
+ collapsed = _widget$collapsed === void 0 ? true : _widget$collapsed,
222
+ _widget$depth = widget.depth,
223
+ depth = _widget$depth === void 0 ? 3 : _widget$depth;
263
224
  if (config.toc !== true || layout !== 'page' && layout !== 'post') {
264
225
  return null;
265
226
  }
266
-
267
227
  return {
268
228
  title: helper._p('widget.catalogue', Infinity),
269
229
  collapsed: collapsed !== false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-component-inferno",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "A collection of Inferno.js layout components and utility scripts for Hexo",
5
5
  "main": "lib/index.js",
6
6
  "repository": "https://github.com/ppoffice/hexo-component-inferno",