hexo-component-inferno 2.0.2 → 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.
@@ -7,7 +7,7 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
7
7
  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); }
8
8
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
9
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
- 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; }
10
+ 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; }
11
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
12
  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); } }
13
13
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -99,14 +99,15 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', function (props
99
99
  config = props.config,
100
100
  page = props.page,
101
101
  helper = props.helper,
102
- _props$type = props.type,
103
- type = _props$type === void 0 ? 'monthly' : _props$type,
104
- _props$order = props.order,
105
- order = _props$order === void 0 ? -1 : _props$order,
106
- _props$showCount = props.showCount,
107
- showCount = _props$showCount === void 0 ? true : _props$showCount,
108
- _props$format = props.format,
109
- format = _props$format === void 0 ? null : _props$format;
102
+ widget = props.widget;
103
+ var _widget$type = widget.type,
104
+ type = _widget$type === void 0 ? 'monthly' : _widget$type,
105
+ _widget$order = widget.order,
106
+ order = _widget$order === void 0 ? -1 : _widget$order,
107
+ _widget$showCount = widget.showCount,
108
+ showCount = _widget$showCount === void 0 ? true : _widget$showCount,
109
+ _widget$format = widget.format,
110
+ format = _widget$format === void 0 ? null : _widget$format;
110
111
  var url_for = helper.url_for,
111
112
  _p = helper._p;
112
113
  var posts = site.posts.sort('date', order);
@@ -127,7 +128,7 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', function (props
127
128
  }
128
129
  var year = date.year();
129
130
  var month = date.month() + 1;
130
- var name = date.format(format || type === 'monthly' ? 'MMMM YYYY' : 'YYYY');
131
+ var name = date.format(format || (type === 'monthly' ? 'MMMM YYYY' : 'YYYY'));
131
132
  var lastData = data[length - 1];
132
133
  if (!lastData || lastData.name !== name) {
133
134
  length = data.push({
@@ -104,16 +104,18 @@ var Categories = /*#__PURE__*/function (_Component) {
104
104
  Categories.Cacheable = cacheComponent(Categories, 'widget.categories', function (props) {
105
105
  var page = props.page,
106
106
  helper = props.helper,
107
- _props$categories = props.categories,
108
- categories = _props$categories === void 0 ? props.site.categories : _props$categories,
109
- _props$orderBy = props.orderBy,
110
- orderBy = _props$orderBy === void 0 ? 'name' : _props$orderBy,
111
- _props$order = props.order,
112
- order = _props$order === void 0 ? 1 : _props$order,
113
- _props$showCurrent = props.showCurrent,
114
- showCurrent = _props$showCurrent === void 0 ? false : _props$showCurrent,
115
- _props$showCount = props.showCount,
116
- showCount = _props$showCount === void 0 ? true : _props$showCount;
107
+ _props$widget = props.widget,
108
+ widget = _props$widget === void 0 ? {} : _props$widget;
109
+ var _widget$categories = widget.categories,
110
+ categories = _widget$categories === void 0 ? props.site.categories : _widget$categories,
111
+ _widget$orderBy = widget.orderBy,
112
+ orderBy = _widget$orderBy === void 0 ? 'name' : _widget$orderBy,
113
+ _widget$order = widget.order,
114
+ order = _widget$order === void 0 ? 1 : _widget$order,
115
+ _widget$showCurrent = widget.showCurrent,
116
+ showCurrent = _widget$showCurrent === void 0 ? false : _widget$showCurrent,
117
+ _widget$showCount = widget.showCount,
118
+ showCount = _widget$showCount === void 0 ? true : _widget$showCount;
117
119
  var url_for = helper.url_for,
118
120
  _p = helper._p;
119
121
  if (!categories || !categories.length) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- var _inferno = require("inferno");
4
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
+ var _inferno = require("inferno");
5
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
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); } }
7
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; }
@@ -52,13 +52,23 @@ var Links = /*#__PURE__*/function (_Component) {
52
52
  var _this$props = this.props,
53
53
  title = _this$props.title,
54
54
  links = _this$props.links;
55
+ for (var name in links) {
56
+ var link = links[name];
57
+ if (typeof link === 'string') {
58
+ link = {
59
+ link: link
60
+ };
61
+ links[name] = link;
62
+ }
63
+ if (link.hide_hostname !== true) {
64
+ try {
65
+ link.hostname = new URL(link.link).hostname;
66
+ } catch (e) {}
67
+ }
68
+ }
55
69
  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", Object.keys(links).map(function (i) {
56
- var hostname = links[i];
57
- if (_typeof(hostname) === 'object') hostname = !hostname.hide_hostname;else try {
58
- hostname = new URL(hostname).hostname;
59
- } catch (e) {}
60
- return (0, _inferno.createVNode)(1, "li", null, (0, _inferno.createVNode)(1, "a", "level is-mobile", [(0, _inferno.createVNode)(1, "span", "level-left", (0, _inferno.createVNode)(1, "span", "level-item", i, 0), 2), hostname ? (0, _inferno.createVNode)(1, "span", "level-right", (0, _inferno.createVNode)(1, "span", "level-item tag", hostname, 0), 2) : null], 0, {
61
- "href": links[i],
70
+ return (0, _inferno.createVNode)(1, "li", null, (0, _inferno.createVNode)(1, "a", "level is-mobile", [(0, _inferno.createVNode)(1, "span", "level-left", (0, _inferno.createVNode)(1, "span", "level-item", i, 0), 2), links[i].hostname ? (0, _inferno.createVNode)(1, "span", "level-right", (0, _inferno.createVNode)(1, "span", "level-item tag", links[i].hostname, 0), 2) : null], 0, {
71
+ "href": links[i].link,
62
72
  "target": "_blank",
63
73
  "rel": "noopener"
64
74
  }), 2);
@@ -91,8 +91,9 @@ var RecentPosts = /*#__PURE__*/function (_Component) {
91
91
  RecentPosts.Cacheable = cacheComponent(RecentPosts, 'widget.recentposts', function (props) {
92
92
  var site = props.site,
93
93
  helper = props.helper,
94
- _props$limit = props.limit,
95
- limit = _props$limit === void 0 ? 5 : _props$limit;
94
+ widget = props.widget;
95
+ var _widget$limit = widget.limit,
96
+ limit = _widget$limit === void 0 ? 5 : _widget$limit;
96
97
  var url_for = helper.url_for,
97
98
  __ = helper.__,
98
99
  date_xml = helper.date_xml,
@@ -16,7 +16,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
16
16
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
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; } } }; }
18
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); }
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; }
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; }
20
20
  /**
21
21
  * Table of contents widget JSX component.
22
22
  * @module view/widget/toc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-component-inferno",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
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",