hexo-component-inferno 4.2.2 → 5.1.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.
- package/README.md +5 -18
- package/asset/css/github-calendar.css +41 -0
- package/asset/js/algolia.js +18 -69
- package/asset/js/github-calendar.js +185 -0
- package/asset/js/google_cse.js +19 -68
- package/asset/js/insight.js +45 -208
- package/lib/core/commented_yaml.js +35 -0
- package/lib/core/default_value.js +150 -0
- package/lib/core/schema.js +8 -196
- package/lib/core/schema_util.js +14 -0
- package/lib/hexo/helper/cdn.js +10 -97
- package/lib/hexo/tag/tabs.js +4 -84
- package/lib/schema/comment/artalk.json +7 -1
- package/lib/schema/comment/cusdis.json +1 -1
- package/lib/schema/comment/facebook.json +1 -1
- package/lib/schema/comment/gitalk.json +23 -6
- package/lib/schema/comment/gitment.json +1 -1
- package/lib/schema/comment/livere.json +9 -3
- package/lib/schema/comment/twikoo.json +3 -3
- package/lib/schema/comment/waline.json +28 -3
- package/lib/schema/misc/open_graph.json +2 -1
- package/lib/schema/plugin/cookie_consent.json +2 -2
- package/lib/schema/plugin/mathjax.json +1 -1
- package/lib/schema/plugin/outdated_browser.json +1 -1
- package/lib/schema/share/bdshare.json +1 -1
- package/lib/schema/share/sharejs.json +1 -1
- package/lib/schema/share/web_share.json +13 -0
- package/lib/schema/widget/github_calendar.json +30 -0
- package/lib/schema/widget/profile.json +67 -0
- package/lib/util/archives.js +86 -0
- package/lib/util/categories.js +102 -0
- package/lib/util/cdn-rules.js +109 -0
- package/lib/util/cdn.js +116 -0
- package/lib/util/consent.js +122 -0
- package/lib/util/deprecate.js +1 -1
- package/lib/util/gallery.js +227 -0
- package/lib/util/insight-search.js +98 -0
- package/lib/util/searchbox.js +88 -0
- package/lib/util/tab-options.js +109 -0
- package/lib/view/comment/artalk.js +24 -6
- package/lib/view/comment/cusdis.js +4 -0
- package/lib/view/comment/disqus.js +1 -1
- package/lib/view/comment/disqusjs.js +7 -6
- package/lib/view/comment/facebook.js +3 -16
- package/lib/view/comment/gitalk.js +18 -15
- package/lib/view/comment/gitment.js +2 -2
- package/lib/view/comment/livere.js +25 -4
- package/lib/view/comment/twikoo.js +5 -3
- package/lib/view/comment/valine.js +4 -3
- package/lib/view/comment/waline.js +8 -6
- package/lib/view/misc/open_graph.js +3 -5
- package/lib/view/plugin/cookie_consent.js +8 -7
- package/lib/view/plugin/gallery.js +42 -19
- package/lib/view/plugin/katex.js +4 -4
- package/lib/view/plugin/mathjax.js +10 -7
- package/lib/view/plugin/outdated_browser.js +59 -45
- package/lib/view/plugin/progressbar.js +6 -1
- package/lib/view/plugin/waline_pageview.js +2 -2
- package/lib/view/search/algolia.js +8 -3
- package/lib/view/search/google_cse.js +13 -10
- package/lib/view/search/insight.js +9 -2
- package/lib/view/share/addthis.js +4 -9
- package/lib/view/share/addtoany.js +23 -5
- package/lib/view/share/bdshare.js +9 -30
- package/lib/view/share/sharejs.js +7 -34
- package/lib/view/share/sharethis.js +21 -6
- package/lib/view/share/web_share.js +153 -0
- package/lib/view/widget/archives.js +19 -71
- package/lib/view/widget/categories.js +20 -67
- package/lib/view/widget/github_calendar.js +94 -0
- package/lib/view/widget/profile.js +194 -0
- package/lib/view/widget/subscribe_email.js +4 -26
- package/package.json +6 -4
|
@@ -17,16 +17,19 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
|
|
|
17
17
|
/**
|
|
18
18
|
* Baidu share buttons JSX component.
|
|
19
19
|
* @module view/share/bdshare
|
|
20
|
+
* @deprecated Retained for compatibility only. Use AddToAny or ShareThis instead.
|
|
20
21
|
*/
|
|
21
22
|
var _require = require('inferno'),
|
|
22
23
|
Component = _require.Component;
|
|
23
24
|
var _require2 = require('../../util/cache'),
|
|
24
25
|
cacheComponent = _require2.cacheComponent;
|
|
26
|
+
var _require3 = require('../../util/deprecate'),
|
|
27
|
+
deprecate = _require3.deprecate;
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* Baidu share buttons JSX component.
|
|
28
31
|
*
|
|
29
|
-
* @
|
|
32
|
+
* @deprecated Legacy integration with HTTP mixed content and obsolete targets. Use AddToAny or ShareThis instead.
|
|
30
33
|
* @example
|
|
31
34
|
* <BdShare />
|
|
32
35
|
*/
|
|
@@ -39,40 +42,16 @@ var BdShare = /*#__PURE__*/function (_Component) {
|
|
|
39
42
|
return _createClass(BdShare, [{
|
|
40
43
|
key: "render",
|
|
41
44
|
value: function render() {
|
|
42
|
-
|
|
43
|
-
return (0, _inferno.
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
}), (0, _inferno.createVNode)(1, "a", "bds_qzone", null, 1, {
|
|
47
|
-
"href": "#",
|
|
48
|
-
"data-cmd": "qzone",
|
|
49
|
-
"title": "分享到QQ空间"
|
|
50
|
-
}), (0, _inferno.createVNode)(1, "a", "bds_tsina", null, 1, {
|
|
51
|
-
"href": "#",
|
|
52
|
-
"data-cmd": "tsina",
|
|
53
|
-
"title": "分享到新浪微博"
|
|
54
|
-
}), (0, _inferno.createVNode)(1, "a", "bds_tqq", null, 1, {
|
|
55
|
-
"href": "#",
|
|
56
|
-
"data-cmd": "tqq",
|
|
57
|
-
"title": "分享到腾讯微博"
|
|
58
|
-
}), (0, _inferno.createVNode)(1, "a", "bds_renren", null, 1, {
|
|
59
|
-
"href": "#",
|
|
60
|
-
"data-cmd": "renren",
|
|
61
|
-
"title": "分享到人人网"
|
|
62
|
-
}), (0, _inferno.createVNode)(1, "a", "bds_weixin", null, 1, {
|
|
63
|
-
"href": "#",
|
|
64
|
-
"data-cmd": "weixin",
|
|
65
|
-
"title": "分享到微信"
|
|
66
|
-
})], 4), (0, _inferno.createVNode)(1, "script", null, null, 1, {
|
|
67
|
-
"dangerouslySetInnerHTML": {
|
|
68
|
-
__html: js
|
|
69
|
-
}
|
|
70
|
-
})], 4);
|
|
45
|
+
deprecate('share.bdshare', 'HTTP mixed content; use AddToAny or ShareThis.');
|
|
46
|
+
return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("This legacy Baidu Share integration is deprecated because it uses HTTP assets and obsolete sharing targets. Set "), (0, _inferno.createVNode)(1, "code", null, "share.type", 16), (0, _inferno.createTextVNode)(" to "), (0, _inferno.createVNode)(1, "code", null, "web_share", 16), (0, _inferno.createTextVNode)(","), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "addtoany", 16), (0, _inferno.createTextVNode)(", or "), (0, _inferno.createVNode)(1, "code", null, "sharethis", 16), (0, _inferno.createTextVNode)(".")], 0, {
|
|
47
|
+
"role": "status"
|
|
48
|
+
});
|
|
71
49
|
}
|
|
72
50
|
}]);
|
|
73
51
|
}(Component);
|
|
74
52
|
/**
|
|
75
53
|
* Cacheable Baidu share buttons JSX component.
|
|
54
|
+
* @deprecated Retained for compatibility only. Use AddToAny or ShareThis instead.
|
|
76
55
|
* <p>
|
|
77
56
|
* This class is supposed to be used in combination with the <code>locals</code> hexo filter
|
|
78
57
|
* ({@link module:hexo/filter/locals}).
|
|
@@ -15,21 +15,15 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
|
|
|
15
15
|
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
16
16
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
17
17
|
/**
|
|
18
|
-
* Share.js
|
|
18
|
+
* Retired Share.js configuration entry.
|
|
19
19
|
* @module view/share/sharejs
|
|
20
20
|
*/
|
|
21
21
|
var _require = require('inferno'),
|
|
22
22
|
Component = _require.Component;
|
|
23
23
|
var _require2 = require('../../util/cache'),
|
|
24
24
|
cacheComponent = _require2.cacheComponent;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* Share.js share buttons JSX component.
|
|
28
|
-
*
|
|
29
|
-
* @see https://github.com/overtrue/share.js
|
|
30
|
-
* @example
|
|
31
|
-
* <ShareJs cssUrl="/path/to/share.css" jsUrl="/path/to/social-share.js" />
|
|
32
|
-
*/
|
|
25
|
+
var _require3 = require('../../util/deprecate'),
|
|
26
|
+
deprecate = _require3.deprecate;
|
|
33
27
|
var ShareJs = /*#__PURE__*/function (_Component) {
|
|
34
28
|
function ShareJs() {
|
|
35
29
|
_classCallCheck(this, ShareJs);
|
|
@@ -39,33 +33,12 @@ var ShareJs = /*#__PURE__*/function (_Component) {
|
|
|
39
33
|
return _createClass(ShareJs, [{
|
|
40
34
|
key: "render",
|
|
41
35
|
value: function render() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
jsUrl = _this$props.jsUrl;
|
|
45
|
-
return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "link", null, null, 1, {
|
|
46
|
-
"rel": "stylesheet",
|
|
47
|
-
"href": cssUrl
|
|
48
|
-
}), (0, _inferno.createVNode)(1, "div", "social-share"), (0, _inferno.createVNode)(1, "script", null, null, 1, {
|
|
49
|
-
"src": jsUrl
|
|
50
|
-
})], 4);
|
|
36
|
+
deprecate('share.sharejs', 'Retired; select web_share or addtoany.');
|
|
37
|
+
return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("Share.js is retired. Set "), (0, _inferno.createVNode)(1, "code", null, "share.type", 16), (0, _inferno.createTextVNode)(" to "), (0, _inferno.createVNode)(1, "code", null, "web_share", 16), (0, _inferno.createTextVNode)(" or"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "addtoany", 16), (0, _inferno.createTextVNode)(".")], 0);
|
|
51
38
|
}
|
|
52
39
|
}]);
|
|
53
40
|
}(Component);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* <p>
|
|
57
|
-
* This class is supposed to be used in combination with the <code>locals</code> hexo filter
|
|
58
|
-
* ({@link module:hexo/filter/locals}).
|
|
59
|
-
*
|
|
60
|
-
* @see module:util/cache.cacheComponent
|
|
61
|
-
* @example
|
|
62
|
-
* <ShareJs.Cacheable helper={{ cdn: function() {...} }} />
|
|
63
|
-
*/
|
|
64
|
-
ShareJs.Cacheable = cacheComponent(ShareJs, 'share.sharejs', function (props) {
|
|
65
|
-
var helper = props.helper;
|
|
66
|
-
return {
|
|
67
|
-
cssUrl: helper.cdn('social-share.js', '1.0.16', 'dist/css/share.min.css'),
|
|
68
|
-
jsUrl: helper.cdn('social-share.js', '1.0.16', 'dist/js/social-share.min.js')
|
|
69
|
-
};
|
|
41
|
+
ShareJs.Cacheable = cacheComponent(ShareJs, 'share.sharejs', function () {
|
|
42
|
+
return {};
|
|
70
43
|
});
|
|
71
44
|
module.exports = ShareJs;
|
|
@@ -22,6 +22,7 @@ var _require = require('inferno'),
|
|
|
22
22
|
Component = _require.Component;
|
|
23
23
|
var _require2 = require('../../util/cache'),
|
|
24
24
|
cacheComponent = _require2.cacheComponent;
|
|
25
|
+
var loadScripts = require('../../util/script');
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* ShareThis share buttons JSX component.
|
|
@@ -39,13 +40,23 @@ var ShareThis = /*#__PURE__*/function (_Component) {
|
|
|
39
40
|
return _createClass(ShareThis, [{
|
|
40
41
|
key: "render",
|
|
41
42
|
value: function render() {
|
|
42
|
-
var
|
|
43
|
+
var _this$props = this.props,
|
|
44
|
+
installUrl = _this$props.installUrl,
|
|
45
|
+
url = _this$props.url,
|
|
46
|
+
title = _this$props.title;
|
|
43
47
|
if (!installUrl) {
|
|
44
48
|
return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You need to set "), (0, _inferno.createVNode)(1, "code", null, "install_url", 16), (0, _inferno.createTextVNode)(" to use ShareThis. Please set it in"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
|
|
45
49
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
50
|
+
var initialize = "\n if (!container || !container.isConnected || container.querySelector('.st-btn')) return;\n var sdk = window.__sharethis__;\n // Reuse the account settings when PJAX replaces the container.\n if (sdk && sdk.config && typeof sdk.load === 'function') {\n var settings = Object.assign({}, sdk.config['inline-share-buttons']);\n if (container.dataset.url) settings.url = container.dataset.url;\n if (container.dataset.title) settings.title = container.dataset.title;\n sdk.load('inline-share-buttons', settings);\n }";
|
|
51
|
+
return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "sharethis-inline-share-buttons", null, 1, {
|
|
52
|
+
"id": "sharethis-share",
|
|
53
|
+
"data-share-provider": "sharethis",
|
|
54
|
+
"data-url": url,
|
|
55
|
+
"data-title": title
|
|
56
|
+
}), (0, _inferno.createVNode)(1, "script", null, null, 1, {
|
|
57
|
+
"dangerouslySetInnerHTML": {
|
|
58
|
+
__html: "(function () {\n var container = document.getElementById('sharethis-share');\n ".concat(loadScripts(installUrl, initialize), "\n })();")
|
|
59
|
+
}
|
|
49
60
|
})], 4);
|
|
50
61
|
}
|
|
51
62
|
}]);
|
|
@@ -61,9 +72,13 @@ var ShareThis = /*#__PURE__*/function (_Component) {
|
|
|
61
72
|
* <ShareThis.Cacheable share={{ install_url: '******' }} />
|
|
62
73
|
*/
|
|
63
74
|
ShareThis.Cacheable = cacheComponent(ShareThis, 'share.sharethis', function (props) {
|
|
64
|
-
var share = props.share
|
|
75
|
+
var share = props.share,
|
|
76
|
+
_props$page = props.page,
|
|
77
|
+
page = _props$page === void 0 ? {} : _props$page;
|
|
65
78
|
return {
|
|
66
|
-
installUrl: share.install_url
|
|
79
|
+
installUrl: share.install_url,
|
|
80
|
+
url: page.permalink,
|
|
81
|
+
title: page.title
|
|
67
82
|
};
|
|
68
83
|
});
|
|
69
84
|
module.exports = ShareThis;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
var _inferno = require("inferno");
|
|
5
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
6
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
7
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
+
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
10
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
11
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
12
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
13
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
15
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
16
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
17
|
+
/**
|
|
18
|
+
* Native Web Share button JSX component.
|
|
19
|
+
* @module view/share/web_share
|
|
20
|
+
*/
|
|
21
|
+
var _require = require('inferno'),
|
|
22
|
+
Component = _require.Component;
|
|
23
|
+
var _require2 = require('../../util/cache'),
|
|
24
|
+
cacheComponent = _require2.cacheComponent;
|
|
25
|
+
|
|
26
|
+
// Brand colors only: the consuming theme owns button geometry and interaction.
|
|
27
|
+
var NETWORKS = [{
|
|
28
|
+
id: 'x',
|
|
29
|
+
name: 'X',
|
|
30
|
+
background: '#000000',
|
|
31
|
+
foreground: '#ffffff'
|
|
32
|
+
}, {
|
|
33
|
+
id: 'facebook',
|
|
34
|
+
name: 'Facebook',
|
|
35
|
+
icon: 'fab fa-facebook-f',
|
|
36
|
+
background: '#0866ff',
|
|
37
|
+
foreground: '#ffffff'
|
|
38
|
+
}, {
|
|
39
|
+
id: 'weibo',
|
|
40
|
+
name: 'Weibo',
|
|
41
|
+
icon: 'fab fa-weibo',
|
|
42
|
+
background: '#e6162d',
|
|
43
|
+
foreground: '#ffffff'
|
|
44
|
+
}, {
|
|
45
|
+
id: 'telegram',
|
|
46
|
+
name: 'Telegram',
|
|
47
|
+
icon: 'fab fa-telegram-plane',
|
|
48
|
+
background: '#26a5e4',
|
|
49
|
+
foreground: '#ffffff'
|
|
50
|
+
}, {
|
|
51
|
+
id: 'linkedin',
|
|
52
|
+
name: 'LinkedIn',
|
|
53
|
+
icon: 'fab fa-linkedin-in',
|
|
54
|
+
background: '#0a66c2',
|
|
55
|
+
foreground: '#ffffff'
|
|
56
|
+
}];
|
|
57
|
+
function shareUrl(network, url, title) {
|
|
58
|
+
var link = encodeURIComponent(url);
|
|
59
|
+
var text = encodeURIComponent(title);
|
|
60
|
+
return {
|
|
61
|
+
x: 'https://twitter.com/intent/tweet?url=' + link + '&text=' + text,
|
|
62
|
+
facebook: 'https://www.facebook.com/sharer/sharer.php?u=' + link,
|
|
63
|
+
weibo: 'https://service.weibo.com/share/share.php?url=' + link + '&title=' + text,
|
|
64
|
+
telegram: 'https://t.me/share/url?url=' + link + '&text=' + text,
|
|
65
|
+
linkedin: 'https://www.linkedin.com/sharing/share-offsite/?url=' + link
|
|
66
|
+
}[network];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Native Web Share button JSX component.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* <WebShare />
|
|
74
|
+
*/
|
|
75
|
+
var WebShare = /*#__PURE__*/function (_Component) {
|
|
76
|
+
function WebShare() {
|
|
77
|
+
_classCallCheck(this, WebShare);
|
|
78
|
+
return _callSuper(this, WebShare, arguments);
|
|
79
|
+
}
|
|
80
|
+
_inherits(WebShare, _Component);
|
|
81
|
+
return _createClass(WebShare, [{
|
|
82
|
+
key: "render",
|
|
83
|
+
value: function render() {
|
|
84
|
+
var _this$props = this.props,
|
|
85
|
+
_this$props$label = _this$props.label,
|
|
86
|
+
label = _this$props$label === void 0 ? 'More' : _this$props$label,
|
|
87
|
+
url = _this$props.url,
|
|
88
|
+
title = _this$props.title;
|
|
89
|
+
var js = "(function () {\n ".concat(shareUrl.toString(), "\n document.querySelectorAll('.hexo-component-share').forEach(function (container) {\n var button = container.querySelector('button');\n var status = container.querySelector('[role=\"status\"]');\n var native = container.querySelector('[data-share-native]');\n var data = { title: container.dataset.title || document.title, url: container.dataset.url || window.location.href };\n container.querySelectorAll('[data-share-network]').forEach(function (link) {\n link.href = shareUrl(link.dataset.shareNetwork, data.url, data.title);\n });\n button.hidden = false;\n native.hidden = false;\n button.disabled = typeof navigator.share !== 'function';\n status.hidden = !button.disabled;\n button.onclick = async function () {\n status.hidden = true;\n try {\n await navigator.share({ title: container.dataset.title || document.title, url: container.dataset.url || window.location.href });\n } catch (error) {\n if (error && error.name === 'AbortError') return;\n status.hidden = false;\n }\n };\n });\n })();");
|
|
90
|
+
return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "hexo-component-share", [(0, _inferno.createVNode)(1, "div", "buttons is-centered", [NETWORKS.map(function (network) {
|
|
91
|
+
return (0, _inferno.createVNode)(1, "a", "button", [(0, _inferno.createVNode)(1, "span", "icon", network.icon ? (0, _inferno.createVNode)(1, "i", network.icon) : (0, _inferno.createVNode)(32, "svg", null, (0, _inferno.createVNode)(32, "path", null, null, 1, {
|
|
92
|
+
"d": "M18.9 2H22l-6.8 7.8L23.2 22h-6.3L12 14.6 5.5 22H2.4l7.9-9L.8 2h6.5l4.5 6.7L18.9 2Zm-1.1 18h1.7L6.4 3.9H4.6L17.8 20Z"
|
|
93
|
+
}), 2, {
|
|
94
|
+
"width": "1em",
|
|
95
|
+
"height": "1em",
|
|
96
|
+
"viewBox": "0 0 24 24",
|
|
97
|
+
"fill": "currentColor"
|
|
98
|
+
}), 0, {
|
|
99
|
+
"aria-hidden": "true"
|
|
100
|
+
}), (0, _inferno.createVNode)(1, "span", null, network.name, 0)], 4, {
|
|
101
|
+
"style": "background-color:".concat(network.background, ";border-color:").concat(network.background, ";color:").concat(network.foreground),
|
|
102
|
+
"data-share-network": network.id,
|
|
103
|
+
"href": shareUrl(network.id, url || '', title || ''),
|
|
104
|
+
"target": "_blank",
|
|
105
|
+
"rel": "noopener noreferrer",
|
|
106
|
+
"aria-label": "Share on ".concat(network.name)
|
|
107
|
+
}, network.id);
|
|
108
|
+
}), (0, _inferno.createVNode)(1, "span", "has-text-centered", (0, _inferno.createVNode)(1, "button", "button", [(0, _inferno.createVNode)(1, "span", "icon", (0, _inferno.createVNode)(1, "i", "fas fa-share-alt"), 2, {
|
|
109
|
+
"aria-hidden": "true"
|
|
110
|
+
}), (0, _inferno.createVNode)(1, "span", null, label, 0)], 4, {
|
|
111
|
+
"type": "button",
|
|
112
|
+
"hidden": true
|
|
113
|
+
}), 2, {
|
|
114
|
+
"data-share-native": "",
|
|
115
|
+
"hidden": true
|
|
116
|
+
})], 0), (0, _inferno.createVNode)(1, "p", null, "System sharing is unavailable in this browser. You can use the platform buttons above.", 16, {
|
|
117
|
+
"role": "status",
|
|
118
|
+
"hidden": true
|
|
119
|
+
})], 4, {
|
|
120
|
+
"data-share-provider": "web_share",
|
|
121
|
+
"data-url": url,
|
|
122
|
+
"data-title": title
|
|
123
|
+
}), (0, _inferno.createVNode)(1, "script", null, null, 1, {
|
|
124
|
+
"dangerouslySetInnerHTML": {
|
|
125
|
+
__html: js
|
|
126
|
+
}
|
|
127
|
+
})], 4);
|
|
128
|
+
}
|
|
129
|
+
}]);
|
|
130
|
+
}(Component);
|
|
131
|
+
/**
|
|
132
|
+
* Cacheable Web Share button JSX component.
|
|
133
|
+
* <p>
|
|
134
|
+
* This class is supposed to be used in combination with the <code>locals</code> hexo filter
|
|
135
|
+
* ({@link module:hexo/filter/locals}).
|
|
136
|
+
*
|
|
137
|
+
* @see module:util/cache.cacheComponent
|
|
138
|
+
* @example
|
|
139
|
+
* <WebShare.Cacheable />
|
|
140
|
+
*/
|
|
141
|
+
WebShare.Cacheable = cacheComponent(WebShare, 'share.web_share', function (_ref) {
|
|
142
|
+
var _ref$config = _ref.config,
|
|
143
|
+
config = _ref$config === void 0 ? {} : _ref$config,
|
|
144
|
+
_ref$page = _ref.page,
|
|
145
|
+
page = _ref$page === void 0 ? {} : _ref$page;
|
|
146
|
+
var language = page.lang || page.language || config.language || 'en';
|
|
147
|
+
return {
|
|
148
|
+
label: /^zh(?:-|$)/i.test([].concat(language)[0]) ? '更多' : 'More',
|
|
149
|
+
url: page.permalink,
|
|
150
|
+
title: page.title
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
module.exports = WebShare;
|
|
@@ -24,39 +24,9 @@ var _require2 = require('../../util/cache'),
|
|
|
24
24
|
cacheComponent = _require2.cacheComponent;
|
|
25
25
|
var _require3 = require('../../util/i18n'),
|
|
26
26
|
translate = _require3.translate;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Convert a Hexo language code into a Moment.js locale name.
|
|
43
|
-
* <p>
|
|
44
|
-
* Same as Hexo's internal <code>toMomentLocale</code>, copied here so that the component does not
|
|
45
|
-
* depend on Hexo's private modules.
|
|
46
|
-
*
|
|
47
|
-
* @param {string} lang Hexo language code, such as <code>zh-CN</code> or <code>en_US</code>.
|
|
48
|
-
* @returns {string|undefined} Moment.js locale name.
|
|
49
|
-
*/
|
|
50
|
-
function toMomentLocale(lang) {
|
|
51
|
-
if (lang === undefined) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
// moment.locale('') and moment.locale(null) both equal moment.locale('en')
|
|
55
|
-
if (!lang || lang === 'en' || lang === 'default') {
|
|
56
|
-
return 'en';
|
|
57
|
-
}
|
|
58
|
-
return lang.toLowerCase().replace('_', '-');
|
|
59
|
-
}
|
|
27
|
+
var _require4 = require('../../util/archives'),
|
|
28
|
+
resolveArchiveOptions = _require4.resolveArchiveOptions,
|
|
29
|
+
groupArchives = _require4.groupArchives;
|
|
60
30
|
|
|
61
31
|
/**
|
|
62
32
|
* Archives widget JSX component.
|
|
@@ -137,13 +107,12 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', function (props
|
|
|
137
107
|
page = props.page,
|
|
138
108
|
helper = props.helper,
|
|
139
109
|
widget = props.widget;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
amount =
|
|
145
|
-
|
|
146
|
-
var showCount = firstSet(widget.show_count, widget.showCount, true);
|
|
110
|
+
var _resolveArchiveOption = resolveArchiveOptions(widget),
|
|
111
|
+
groupBy = _resolveArchiveOption.groupBy,
|
|
112
|
+
order = _resolveArchiveOption.order,
|
|
113
|
+
format = _resolveArchiveOption.format,
|
|
114
|
+
amount = _resolveArchiveOption.amount,
|
|
115
|
+
showCount = _resolveArchiveOption.showCount;
|
|
147
116
|
var url_for = helper.url_for,
|
|
148
117
|
_p = helper._p,
|
|
149
118
|
__ = helper.__;
|
|
@@ -151,33 +120,15 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', function (props
|
|
|
151
120
|
if (!posts.length) {
|
|
152
121
|
return null;
|
|
153
122
|
}
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (language) {
|
|
164
|
-
date = date.locale(language);
|
|
165
|
-
}
|
|
166
|
-
var year = date.year();
|
|
167
|
-
var month = date.month() + 1;
|
|
168
|
-
var name = date.format(format || (groupBy === 'monthly' ? 'MMMM YYYY' : 'YYYY'));
|
|
169
|
-
var lastData = data[length - 1];
|
|
170
|
-
if (!lastData || lastData.name !== name) {
|
|
171
|
-
length = data.push({
|
|
172
|
-
name: name,
|
|
173
|
-
year: year,
|
|
174
|
-
month: month,
|
|
175
|
-
count: 1
|
|
176
|
-
});
|
|
177
|
-
} else {
|
|
178
|
-
lastData.count++;
|
|
179
|
-
}
|
|
180
|
-
});
|
|
123
|
+
var _groupArchives = groupArchives(posts, {
|
|
124
|
+
groupBy: groupBy,
|
|
125
|
+
format: format,
|
|
126
|
+
amount: amount,
|
|
127
|
+
language: page.lang || page.language || config.language,
|
|
128
|
+
timezone: config.timezone
|
|
129
|
+
}),
|
|
130
|
+
groups = _groupArchives.groups,
|
|
131
|
+
hasMore = _groupArchives.hasMore;
|
|
181
132
|
var link = function link(item) {
|
|
182
133
|
var url = "".concat(config.archive_dir, "/").concat(item.year, "/");
|
|
183
134
|
if (groupBy === 'monthly') {
|
|
@@ -186,11 +137,8 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', function (props
|
|
|
186
137
|
}
|
|
187
138
|
return url_for(url);
|
|
188
139
|
};
|
|
189
|
-
|
|
190
|
-
// Link to the archive page when some of the archives are not shown
|
|
191
|
-
var hasMore = amount > 0 && data.length > amount;
|
|
192
140
|
return {
|
|
193
|
-
items:
|
|
141
|
+
items: groups.map(function (item) {
|
|
194
142
|
return {
|
|
195
143
|
name: item.name,
|
|
196
144
|
count: item.count,
|
|
@@ -24,19 +24,10 @@ var _require2 = require('../../util/cache'),
|
|
|
24
24
|
cacheComponent = _require2.cacheComponent;
|
|
25
25
|
var _require3 = require('../../util/i18n'),
|
|
26
26
|
translate = _require3.translate;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
}
|
|
27
|
+
var _require4 = require('../../util/categories'),
|
|
28
|
+
resolveCategoryOptions = _require4.resolveCategoryOptions,
|
|
29
|
+
resolveCategoryDepth = _require4.resolveCategoryDepth,
|
|
30
|
+
prepareCategories = _require4.prepareCategories;
|
|
40
31
|
|
|
41
32
|
/**
|
|
42
33
|
* Categories widget JSX component.
|
|
@@ -128,68 +119,30 @@ Categories.Cacheable = cacheComponent(Categories, 'widget.categories', function
|
|
|
128
119
|
var _widget$categories = widget.categories,
|
|
129
120
|
categories = _widget$categories === void 0 ? props.site.categories : _widget$categories,
|
|
130
121
|
amount = widget.amount;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
var showCount = firstSet(widget.show_count, widget.showCount, true);
|
|
122
|
+
var _resolveCategoryOptio = resolveCategoryOptions(widget),
|
|
123
|
+
order = _resolveCategoryOptio.order,
|
|
124
|
+
orderBy = _resolveCategoryOptio.orderBy,
|
|
125
|
+
showCurrent = _resolveCategoryOptio.showCurrent,
|
|
126
|
+
showCount = _resolveCategoryOptio.showCount;
|
|
137
127
|
var url_for = helper.url_for,
|
|
138
128
|
_p = helper._p,
|
|
139
129
|
__ = helper.__;
|
|
140
130
|
if (!categories || !categories.length) {
|
|
141
131
|
return null;
|
|
142
132
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
return categories.find(query).sort(orderBy, order).filter(function (cat) {
|
|
156
|
-
return cat.length;
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
function hierarchicalList(level, parent) {
|
|
160
|
-
return prepareQuery(parent).map(function (cat, i) {
|
|
161
|
-
var children = [];
|
|
162
|
-
if (!depth || level + 1 < depth) {
|
|
163
|
-
children = hierarchicalList(level + 1, cat._id);
|
|
164
|
-
}
|
|
165
|
-
var isCurrent = false;
|
|
166
|
-
if (showCurrent && page) {
|
|
167
|
-
for (var j = 0; j < cat.length; j++) {
|
|
168
|
-
var post = cat.posts.data[j];
|
|
169
|
-
if (post && post._id === page._id) {
|
|
170
|
-
isCurrent = true;
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
// special case: category page
|
|
175
|
-
isCurrent = isCurrent || page.base && page.base.startsWith(cat.path);
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
children: children,
|
|
179
|
-
isCurrent: isCurrent,
|
|
180
|
-
name: cat.name,
|
|
181
|
-
count: cat.length,
|
|
182
|
-
url: url_for(cat.path)
|
|
183
|
-
};
|
|
184
|
-
});
|
|
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;
|
|
133
|
+
var depth = resolveCategoryDepth(widget.depth, props.depth);
|
|
134
|
+
var _prepareCategories = prepareCategories(categories, {
|
|
135
|
+
order: order,
|
|
136
|
+
orderBy: orderBy,
|
|
137
|
+
showCurrent: showCurrent,
|
|
138
|
+
depth: depth,
|
|
139
|
+
amount: amount
|
|
140
|
+
}, page, url_for),
|
|
141
|
+
list = _prepareCategories.categories,
|
|
142
|
+
hasMore = _prepareCategories.hasMore;
|
|
190
143
|
return {
|
|
191
144
|
showCount: showCount,
|
|
192
|
-
categories:
|
|
145
|
+
categories: list,
|
|
193
146
|
title: _p('common.category', Infinity),
|
|
194
147
|
moreUrl: hasMore ? url_for('categories/') : null,
|
|
195
148
|
moreTitle: translate(__, 'widget.more', 'More')
|