hexo-component-inferno 4.0.0 → 4.2.0

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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -8
  3. package/asset/js/algolia.js +27 -10
  4. package/asset/js/insight.js +62 -44
  5. package/lib/core/migrate.js +23 -4
  6. package/lib/core/schema.js +31 -9
  7. package/lib/core/view.js +1 -1
  8. package/lib/hexo/filter/locals.js +5 -2
  9. package/lib/hexo/generator/category.js +8 -1
  10. package/lib/hexo/generator/insight.js +8 -15
  11. package/lib/hexo/generator/manifest.js +6 -0
  12. package/lib/hexo/helper/cdn.js +11 -3
  13. package/lib/hexo/tag/message.js +11 -1
  14. package/lib/hexo/tag/tabs.js +28 -5
  15. package/lib/schema/comment/artalk.json +37 -0
  16. package/lib/schema/comment/beaudar.json +62 -0
  17. package/lib/schema/comment/cusdis.json +34 -0
  18. package/lib/schema/comment/giscus.json +12 -1
  19. package/lib/schema/comment/gitment.json +1 -1
  20. package/lib/schema/comment/utterances.json +15 -1
  21. package/lib/schema/comment/valine.json +1 -1
  22. package/lib/schema/comment/waline.json +2 -2
  23. package/lib/schema/misc/open_graph.json +0 -1
  24. package/lib/schema/plugin/waline_pageview.json +14 -0
  25. package/lib/schema/share/addthis.json +1 -1
  26. package/lib/schema/widget/archives.json +28 -0
  27. package/lib/schema/widget/categories.json +32 -0
  28. package/lib/schema/widget/recent_posts.json +5 -0
  29. package/lib/schema/widget/subscribe_email.json +1 -1
  30. package/lib/schema/widget/tags.json +1 -1
  31. package/lib/util/appearance.js +40 -0
  32. package/lib/util/classname.js +1 -1
  33. package/lib/util/deprecate.js +28 -0
  34. package/lib/util/html.js +51 -0
  35. package/lib/util/i18n.js +24 -0
  36. package/lib/util/script.js +73 -5
  37. package/lib/view/comment/artalk.js +119 -0
  38. package/lib/view/comment/beaudar.js +134 -0
  39. package/lib/view/comment/changyan.js +2 -1
  40. package/lib/view/comment/cusdis.js +120 -0
  41. package/lib/view/comment/disqus.js +3 -1
  42. package/lib/view/comment/disqusjs.js +3 -2
  43. package/lib/view/comment/facebook.js +3 -1
  44. package/lib/view/comment/giscus.js +32 -21
  45. package/lib/view/comment/gitalk.js +4 -2
  46. package/lib/view/comment/gitment.js +7 -2
  47. package/lib/view/comment/isso.js +5 -1
  48. package/lib/view/comment/twikoo.js +5 -1
  49. package/lib/view/comment/utterances.js +26 -16
  50. package/lib/view/comment/valine.js +7 -1
  51. package/lib/view/comment/waline.js +31 -21
  52. package/lib/view/donate/afdian.js +1 -1
  53. package/lib/view/donate/alipay.js +1 -1
  54. package/lib/view/donate/buymeacoffee.js +1 -1
  55. package/lib/view/donate/patreon.js +1 -1
  56. package/lib/view/donate/wechat.js +1 -1
  57. package/lib/view/misc/meta.js +9 -3
  58. package/lib/view/misc/open_graph.js +12 -15
  59. package/lib/view/misc/structured_data.js +8 -9
  60. package/lib/view/misc/web_app.js +15 -6
  61. package/lib/view/plugin/baidu_analytics.js +3 -1
  62. package/lib/view/plugin/cookie_consent.js +3 -1
  63. package/lib/view/plugin/google_analytics.js +3 -1
  64. package/lib/view/plugin/hotjar.js +3 -1
  65. package/lib/view/plugin/matomo.js +3 -1
  66. package/lib/view/plugin/outdated_browser.js +1 -1
  67. package/lib/view/plugin/statcounter.js +3 -1
  68. package/lib/view/plugin/twitter_conversion_tracking.js +3 -1
  69. package/lib/view/plugin/waline_pageview.js +100 -0
  70. package/lib/view/search/algolia.js +3 -1
  71. package/lib/view/search/baidu.js +3 -1
  72. package/lib/view/search/google_cse.js +3 -1
  73. package/lib/view/search/insight.js +4 -2
  74. package/lib/view/share/addthis.js +4 -0
  75. package/lib/view/widget/archives.js +37 -9
  76. package/lib/view/widget/categories.js +41 -15
  77. package/lib/view/widget/links.js +1 -1
  78. package/lib/view/widget/subscribe_email.js +5 -0
  79. package/lib/view/widget/tags.js +18 -5
  80. package/package.json +4 -2
@@ -22,6 +22,21 @@ var _require = require('inferno'),
22
22
  Component = _require.Component;
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/i18n'),
26
+ translate = _require3.translate;
27
+
28
+ /**
29
+ * Get the first value that is set, i.e., neither null nor undefined.
30
+ * @private
31
+ */
32
+ function firstSet() {
33
+ for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
34
+ values[_key] = arguments[_key];
35
+ }
36
+ return values.find(function (value) {
37
+ return value !== null && typeof value !== 'undefined';
38
+ });
39
+ }
25
40
 
26
41
  /**
27
42
  * Categories widget JSX component.
@@ -66,8 +81,14 @@ var Categories = /*#__PURE__*/function (_Component) {
66
81
  var _this$props = this.props,
67
82
  title = _this$props.title,
68
83
  showCount = _this$props.showCount,
69
- categories = _this$props.categories;
70
- 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", title, 0), (0, _inferno.createVNode)(1, "ul", "menu-list", this.renderList(categories, showCount), 0)], 4), 2), 2, {
84
+ categories = _this$props.categories,
85
+ moreUrl = _this$props.moreUrl,
86
+ moreTitle = _this$props.moreTitle;
87
+ 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", title, 0), (0, _inferno.createVNode)(1, "ul", "menu-list", [this.renderList(categories, showCount), moreUrl ? (0, _inferno.createVNode)(1, "li", null, (0, _inferno.createVNode)(1, "a", "level is-mobile", [(0, _inferno.createVNode)(1, "span", "level-start", (0, _inferno.createVNode)(1, "span", "level-item", moreTitle, 0), 2), (0, _inferno.createVNode)(1, "span", "level-end", (0, _inferno.createVNode)(1, "span", "level-item icon is-small", (0, _inferno.createVNode)(1, "i", "fas fa-chevron-right"), 2, {
88
+ "aria-hidden": "true"
89
+ }), 2)], 4, {
90
+ "href": moreUrl
91
+ }), 2) : null], 0)], 4), 2), 2, {
71
92
  "data-type": "categories"
72
93
  });
73
94
  }
@@ -106,23 +127,22 @@ Categories.Cacheable = cacheComponent(Categories, 'widget.categories', function
106
127
  widget = _props$widget === void 0 ? {} : _props$widget;
107
128
  var _widget$categories = widget.categories,
108
129
  categories = _widget$categories === void 0 ? props.site.categories : _widget$categories,
109
- _widget$orderBy = widget.orderBy,
110
- orderBy = _widget$orderBy === void 0 ? 'name' : _widget$orderBy,
111
130
  _widget$order = widget.order,
112
131
  order = _widget$order === void 0 ? 1 : _widget$order,
113
- _widget$showCurrent = widget.showCurrent,
114
- showCurrent = _widget$showCurrent === void 0 ? false : _widget$showCurrent,
115
- _widget$showCount = widget.showCount,
116
- showCount = _widget$showCount === void 0 ? true : _widget$showCount;
132
+ amount = widget.amount;
133
+ // Snake case, like the tags widget, or camel case, which this widget used to read
134
+ var orderBy = firstSet(widget.order_by, widget.orderBy, 'name');
135
+ var showCurrent = firstSet(widget.show_current, widget.showCurrent, false);
136
+ var showCount = firstSet(widget.show_count, widget.showCount, true);
117
137
  var url_for = helper.url_for,
118
- _p = helper._p;
138
+ _p = helper._p,
139
+ __ = helper.__;
119
140
  if (!categories || !categories.length) {
120
141
  return null;
121
142
  }
122
- var depth = 0;
123
- try {
124
- depth = parseInt(props.depth, 10);
125
- } catch (e) {}
143
+
144
+ // 0 or no depth shows all levels
145
+ var depth = parseInt(firstSet(widget.depth, props.depth), 10) || 0;
126
146
  function prepareQuery(parent) {
127
147
  var query = {};
128
148
  if (parent) {
@@ -163,10 +183,16 @@ Categories.Cacheable = cacheComponent(Categories, 'widget.categories', function
163
183
  };
164
184
  });
165
185
  }
186
+
187
+ // Only limit the top-level categories, and link to the category page when some are not shown
188
+ var list = hierarchicalList(0);
189
+ var hasMore = amount > 0 && list.length > amount;
166
190
  return {
167
191
  showCount: showCount,
168
- categories: hierarchicalList(0),
169
- title: _p('common.category', Infinity)
192
+ categories: hasMore ? list.slice(0, amount) : list,
193
+ title: _p('common.category', Infinity),
194
+ moreUrl: hasMore ? url_for('categories/') : null,
195
+ moreTitle: translate(__, 'widget.more', 'More')
170
196
  };
171
197
  });
172
198
  module.exports = Categories;
@@ -95,7 +95,7 @@ var Links = /*#__PURE__*/function (_Component) {
95
95
  Links.Cacheable = cacheComponent(Links, 'widget.links', function (props) {
96
96
  var helper = props.helper,
97
97
  widget = props.widget;
98
- if (!Object.keys(widget.links).length) {
98
+ if (!widget.links || !Object.keys(widget.links).length) {
99
99
  return null;
100
100
  }
101
101
  return {
@@ -22,10 +22,14 @@ var _require = require('inferno'),
22
22
  Component = _require.Component;
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/deprecate'),
26
+ deprecate = _require3.deprecate;
25
27
 
26
28
  /**
27
29
  * Google FeedBurner widget JSX component.
28
30
  *
31
+ * @deprecated Google FeedBurner stopped email subscriptions in July 2021. Use the follow.it widget
32
+ * instead.
29
33
  * @see https://feedburner.google.com/
30
34
  * @example
31
35
  * <SubscribeEmail
@@ -43,6 +47,7 @@ var SubscribeEmail = /*#__PURE__*/function (_Component) {
43
47
  return _createClass(SubscribeEmail, [{
44
48
  key: "render",
45
49
  value: function render() {
50
+ deprecate('widget.subscribe_email', 'Google FeedBurner stopped email subscriptions in July 2021. Use the follow.it widget instead.');
46
51
  var _this$props = this.props,
47
52
  title = _this$props.title,
48
53
  description = _this$props.description,
@@ -22,6 +22,8 @@ var _require = require('inferno'),
22
22
  Component = _require.Component;
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/i18n'),
26
+ translate = _require3.translate;
25
27
 
26
28
  /**
27
29
  * Tags widget JSX component.
@@ -50,12 +52,18 @@ var Tags = /*#__PURE__*/function (_Component) {
50
52
  var _this$props = this.props,
51
53
  tags = _this$props.tags,
52
54
  title = _this$props.title,
53
- showCount = _this$props.showCount;
54
- 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", title, 0), (0, _inferno.createVNode)(1, "div", "field is-grouped is-grouped-multiline", tags.map(function (tag) {
55
+ showCount = _this$props.showCount,
56
+ moreUrl = _this$props.moreUrl,
57
+ moreTitle = _this$props.moreTitle;
58
+ 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", title, 0), (0, _inferno.createVNode)(1, "div", "field is-grouped is-grouped-multiline", [tags.map(function (tag) {
55
59
  return (0, _inferno.createVNode)(1, "div", "control", (0, _inferno.createVNode)(1, "a", "tags has-addons", [(0, _inferno.createVNode)(1, "span", "tag", tag.name, 0), showCount ? (0, _inferno.createVNode)(1, "span", "tag", tag.count, 0) : null], 0, {
56
60
  "href": tag.url
57
61
  }), 2);
58
- }), 0)], 4), 2), 2, {
62
+ }), moreUrl ? (0, _inferno.createVNode)(1, "div", "control", (0, _inferno.createVNode)(1, "a", "tags has-addons", (0, _inferno.createVNode)(1, "span", "tag", [(0, _inferno.createVNode)(1, "span", null, moreTitle, 0), (0, _inferno.createVNode)(1, "span", "icon is-small", (0, _inferno.createVNode)(1, "i", "fas fa-chevron-right"), 2, {
63
+ "aria-hidden": "true"
64
+ })], 4), 2, {
65
+ "href": moreUrl
66
+ }), 2) : null], 0)], 4), 2), 2, {
59
67
  "data-type": "tags"
60
68
  });
61
69
  }
@@ -94,19 +102,24 @@ Tags.Cacheable = cacheComponent(Tags, 'widget.tags', function (props) {
94
102
  show_count = _widget$show_count === void 0 ? true : _widget$show_count;
95
103
  var tags = props.tags || props.site.tags;
96
104
  var url_for = helper.url_for,
97
- _p = helper._p;
105
+ _p = helper._p,
106
+ __ = helper.__;
98
107
  if (!tags || !tags.length) {
99
108
  return null;
100
109
  }
101
110
  tags = tags.sort(order_by).filter(function (tag) {
102
111
  return tag.length;
103
112
  });
104
- if (amount) {
113
+ // Link to the tag page when some of the tags are not shown
114
+ var hasMore = amount > 0 && tags.length > amount;
115
+ if (hasMore) {
105
116
  tags = tags.limit(amount);
106
117
  }
107
118
  return {
108
119
  showCount: show_count,
109
120
  title: _p('common.tag', Infinity),
121
+ moreUrl: hasMore ? url_for('tags/') : null,
122
+ moreTitle: translate(__, 'widget.more', 'More'),
110
123
  tags: tags.map(function (tag) {
111
124
  return {
112
125
  name: tag.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-component-inferno",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
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",
@@ -44,13 +44,15 @@
44
44
  "eslint-plugin-jest": "^27.6.3",
45
45
  "eslint-plugin-json": "^3.1.0",
46
46
  "eslint-plugin-react": "^7.33.2",
47
- "hexo": "^7.1.1",
47
+ "hexo": "^8.1.2",
48
48
  "hexo-renderer-marked": "^6.2.0",
49
49
  "html-minifier": "^4.0.0",
50
50
  "inferno-server": "^8.2.3",
51
51
  "inferno-test-utils": "^8.2.3",
52
52
  "jest": "^29.7.0",
53
53
  "jest-environment-jsdom": "^29.7.0",
54
+ "jquery": "^3.7.1",
55
+ "jsdom": "^20.0.3",
54
56
  "jsdoc": "^4.0.2",
55
57
  "minami": "^1.2.3",
56
58
  "prettier": "^3.2.4",