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
@@ -26,9 +26,9 @@ var moment = require('moment');
26
26
  var _require = require('inferno'),
27
27
  Component = _require.Component;
28
28
  var _require2 = require('hexo-util'),
29
- encodeURL = _require2.encodeURL,
30
- stripHTML = _require2.stripHTML,
31
- escapeHTML = _require2.escapeHTML;
29
+ encodeURL = _require2.encodeURL;
30
+ var _require3 = require('../../util/html'),
31
+ toPlainText = _require3.toPlainText;
32
32
  var localeMap = {
33
33
  en: 'en_US',
34
34
  de: 'de_DE',
@@ -45,7 +45,6 @@ var localeMap = {
45
45
  tr: 'tr_TR',
46
46
  vi: 'vi_VN'
47
47
  };
48
- var localeRegex = new RegExp(Object.keys(localeMap).join('|'), 'i');
49
48
 
50
49
  /**
51
50
  * A JSX component that renders Open Graph tags.
@@ -103,7 +102,8 @@ module.exports = /*#__PURE__*/function (_Component) {
103
102
  twitterId = _this$props2.twitterId;
104
103
  var htmlTags = [];
105
104
  if (description) {
106
- description = escapeHTML(stripHTML(description).substring(0, 200).trim()).replace(/\n/g, ' ');
105
+ // Plain text, which Inferno escapes in the attribute
106
+ description = toPlainText(description).substring(0, 200).trim();
107
107
  htmlTags.push((0, _inferno.createVNode)(1, "meta", null, null, 1, {
108
108
  "name": "description",
109
109
  "content": description
@@ -133,13 +133,12 @@ module.exports = /*#__PURE__*/function (_Component) {
133
133
  }
134
134
  if (language) {
135
135
  if (language.length === 2) {
136
- language = language.replace(localeRegex, function (str) {
137
- return localeMap[str];
138
- });
139
- htmlTags.push((0, _inferno.createVNode)(1, "meta", null, null, 1, {
140
- "property": "og:locale",
141
- "content": language
142
- }));
136
+ if (localeMap[language.toLowerCase()]) {
137
+ htmlTags.push((0, _inferno.createVNode)(1, "meta", null, null, 1, {
138
+ "property": "og:locale",
139
+ "content": localeMap[language.toLowerCase()]
140
+ }));
141
+ }
143
142
  } else if (language.length === 5) {
144
143
  var territory = language.slice(-2);
145
144
  var territoryRegex = new RegExp(territory.concat('$'));
@@ -150,9 +149,7 @@ module.exports = /*#__PURE__*/function (_Component) {
150
149
  }));
151
150
  }
152
151
  }
153
- if (!Array.isArray(images)) {
154
- images = [images];
155
- }
152
+ images = [].concat(images || []).filter(Boolean);
156
153
  images.map(function (path) {
157
154
  if (!urlFn.parse(path).host) {
158
155
  // resolve `path`'s absolute path relative to current page's url
@@ -22,9 +22,10 @@ var urlFn = require('url');
22
22
  var moment = require('moment');
23
23
  var _require = require('inferno'),
24
24
  Component = _require.Component;
25
- var _require2 = require('hexo-util'),
26
- stripHTML = _require2.stripHTML,
27
- escapeHTML = _require2.escapeHTML;
25
+ var _require2 = require('../../util/script'),
26
+ toJs = _require2.toJs;
27
+ var _require3 = require('../../util/html'),
28
+ toPlainText = _require3.toPlainText;
28
29
 
29
30
  /**
30
31
  * A JSX component that renders simple Google structured data.
@@ -63,11 +64,9 @@ module.exports = /*#__PURE__*/function (_Component) {
63
64
  updated = _this$props2.updated,
64
65
  publisherLogo = _this$props2.publisherLogo;
65
66
  if (description) {
66
- description = escapeHTML(stripHTML(description).substring(0, 200).trim()).replace(/\n/g, ' ');
67
- }
68
- if (!Array.isArray(images)) {
69
- images = [images];
67
+ description = toPlainText(description).substring(0, 200).trim();
70
68
  }
69
+ images = [].concat(images || []).filter(Boolean);
71
70
  images = images.map(function (path) {
72
71
  if (!urlFn.parse(path).host) {
73
72
  // resolve `path`'s absolute path relative to current page's url
@@ -76,7 +75,7 @@ module.exports = /*#__PURE__*/function (_Component) {
76
75
  }
77
76
  return path;
78
77
  }).filter(function (url) {
79
- return url.endsWith('.jpg') || url.endsWith('.png') || url.endsWith('.gif') || url.endsWith('.webp');
78
+ return /\.(jpe?g|png|gif|webp|avif|svg)$/i.test(urlFn.parse(url).pathname || '');
80
79
  });
81
80
  if (typeof publisherLogo === 'string' && !urlFn.parse(publisherLogo).host) {
82
81
  publisherLogo = urlFn.resolve(url, publisherLogo);
@@ -115,7 +114,7 @@ module.exports = /*#__PURE__*/function (_Component) {
115
114
  return (0, _inferno.createVNode)(1, "script", null, null, 1, {
116
115
  "type": "application/ld+json",
117
116
  "dangerouslySetInnerHTML": {
118
- __html: JSON.stringify(data)
117
+ __html: toJs(data)
119
118
  }
120
119
  });
121
120
  }
@@ -2,6 +2,9 @@
2
2
 
3
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
4
  var _inferno = require("inferno");
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
8
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
6
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
10
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -132,28 +135,34 @@ WebApp.Cacheable = cacheComponent(WebApp, 'misc.webapp', function (props) {
132
135
  var name = props.name,
133
136
  themeColor = props.themeColor,
134
137
  favicon = props.favicon,
135
- icons = props.icons,
136
138
  helper = props.helper;
139
+ var url_for = helper.url_for;
140
+ // Resolve the icons against the root of the site, like the manifest
141
+ var icons = Array.isArray(props.icons) ? props.icons.map(function (icon) {
142
+ return icon && icon.src ? _objectSpread(_objectSpread({}, icon), {}, {
143
+ src: url_for(icon.src)
144
+ }) : icon;
145
+ }) : props.icons;
137
146
  var tileIcon = null;
138
147
  if (Array.isArray(icons)) {
139
148
  tileIcon = icons.find(function (icon) {
140
- return icon.sizes.toLowerCase().indexOf('144x144') > -1;
149
+ return icon && typeof icon.sizes === 'string' && icon.sizes.toLowerCase().indexOf('144x144') > -1;
141
150
  });
142
151
  if (tileIcon) {
143
152
  tileIcon = tileIcon.src;
144
153
  } else if (icons.length) {
145
- tileIcon = icons[0].src;
154
+ tileIcon = (icons[0] || {}).src;
146
155
  }
147
156
  }
148
- if (!tileIcon) {
149
- tileIcon = favicon;
157
+ if (!tileIcon && favicon) {
158
+ tileIcon = url_for(favicon);
150
159
  }
151
160
  return {
152
161
  name: name,
153
162
  icons: icons,
154
163
  tileIcon: tileIcon,
155
164
  themeColor: themeColor,
156
- manifest: helper.url_for('/manifest.json')
165
+ manifest: url_for('/manifest.json')
157
166
  };
158
167
  });
159
168
  module.exports = WebApp;
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Baidu Analytics plugin JSX component.
@@ -40,7 +42,7 @@ var BaiduAnalytics = /*#__PURE__*/function (_Component) {
40
42
  key: "render",
41
43
  value: function render() {
42
44
  var trackingId = this.props.trackingId;
43
- var js = "var _hmt = _hmt || [];\n (function() {\n var hm = document.createElement(\"script\");\n hm.src = \"//hm.baidu.com/hm.js?".concat(trackingId, "\";\n var s = document.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(hm, s);\n })();");
45
+ var js = "var _hmt = _hmt || [];\n (function() {\n var hm = document.createElement(\"script\");\n hm.src = ".concat(toJs("//hm.baidu.com/hm.js?".concat(trackingId)), ";\n var s = document.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(hm, s);\n })();");
44
46
  return (0, _inferno.createVNode)(1, "script", null, null, 1, {
45
47
  "dangerouslySetInnerHTML": {
46
48
  __html: js
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * A JSX component for alerting users about the use of cookies.
@@ -71,7 +73,7 @@ var CookieConsent = /*#__PURE__*/function (_Component) {
71
73
  deny = text.deny,
72
74
  link = text.link,
73
75
  policy = text.policy;
74
- var js = "window.addEventListener(\"load\", () => {\n window.cookieconsent.initialise({\n type: ".concat(JSON.stringify(type), ",\n theme: ").concat(JSON.stringify(theme), ",\n static: ").concat(JSON.stringify(this.props["static"]), ",\n position: ").concat(JSON.stringify(position), ",\n content: {\n message: ").concat(JSON.stringify(message), ",\n dismiss: ").concat(JSON.stringify(dismiss), ",\n allow: ").concat(JSON.stringify(allow), ",\n deny: ").concat(JSON.stringify(deny), ",\n link: ").concat(JSON.stringify(link), ",\n policy: ").concat(JSON.stringify(policy), ",\n href: ").concat(JSON.stringify(policyLink), ",\n },\n palette: {\n popup: {\n background: \"#edeff5\",\n text: \"#838391\"\n },\n button: {\n background: \"#4b81e8\"\n },\n },\n });\n });");
76
+ var js = "window.addEventListener(\"load\", () => {\n window.cookieconsent.initialise({\n type: ".concat(toJs(type), ",\n theme: ").concat(toJs(theme), ",\n static: ").concat(toJs(this.props["static"]), ",\n position: ").concat(toJs(position), ",\n content: {\n message: ").concat(toJs(message), ",\n dismiss: ").concat(toJs(dismiss), ",\n allow: ").concat(toJs(allow), ",\n deny: ").concat(toJs(deny), ",\n link: ").concat(toJs(link), ",\n policy: ").concat(toJs(policy), ",\n href: ").concat(toJs(policyLink), ",\n },\n palette: {\n popup: {\n background: \"#edeff5\",\n text: \"#838391\"\n },\n button: {\n background: \"#4b81e8\"\n },\n },\n });\n });");
75
77
  if (head) {
76
78
  return (0, _inferno.createVNode)(1, "link", null, null, 1, {
77
79
  "rel": "stylesheet",
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Google Analytics plugin JSX component.
@@ -40,7 +42,7 @@ var GoogleAnalytics = /*#__PURE__*/function (_Component) {
40
42
  key: "render",
41
43
  value: function render() {
42
44
  var trackingId = this.props.trackingId;
43
- var js = "window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n \n gtag('config', '".concat(trackingId, "');");
45
+ var js = "window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n \n gtag('config', ".concat(toJs(trackingId), ");");
44
46
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "script", null, null, 1, {
45
47
  "src": "https://www.googletagmanager.com/gtag/js?id=".concat(trackingId),
46
48
  "async": true
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Hotjar user feedback plugin JSX component.
@@ -40,7 +42,7 @@ var Hotjar = /*#__PURE__*/function (_Component) {
40
42
  key: "render",
41
43
  value: function render() {
42
44
  var siteId = this.props.siteId;
43
- var js = "(function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:".concat(siteId, ",hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');");
45
+ var js = "(function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:".concat(toJs(siteId), ",hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');");
44
46
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "script", null, null, 1, {
45
47
  "dangerouslySetInnerHTML": {
46
48
  __html: js
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Matomo analytics plugin JSX component.
@@ -49,7 +51,7 @@ var Matomo = /*#__PURE__*/function (_Component) {
49
51
  siteId = _this$props.siteId,
50
52
  disableCookies = _this$props.disableCookies;
51
53
  var baseUrl = url.endsWith('/') ? url : url + '/';
52
- var js = "var _paq = window._paq = window._paq || [];\n ".concat(disableCookies ? "_paq.push(['disableCookies']);" : '', "\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n (function () {\n var u = ").concat(JSON.stringify(baseUrl), ";\n _paq.push(['setTrackerUrl', u + 'matomo.php']);\n _paq.push(['setSiteId', ").concat(JSON.stringify(String(siteId)), "]);\n var g = document.createElement('script');\n g.async = true;\n g.src = u + 'matomo.js';\n document.head.appendChild(g);\n })();\n (function () {\n var referrer = location.href;\n document.addEventListener('pjax:complete', function () {\n _paq.push(['setReferrerUrl', referrer]);\n referrer = location.href;\n _paq.push(['setCustomUrl', referrer]);\n _paq.push(['setDocumentTitle', document.title]);\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n });\n })();");
54
+ var js = "var _paq = window._paq = window._paq || [];\n ".concat(disableCookies ? "_paq.push(['disableCookies']);" : '', "\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n (function () {\n var u = ").concat(toJs(baseUrl), ";\n _paq.push(['setTrackerUrl', u + 'matomo.php']);\n _paq.push(['setSiteId', ").concat(toJs(String(siteId)), "]);\n var g = document.createElement('script');\n g.async = true;\n g.src = u + 'matomo.js';\n document.head.appendChild(g);\n })();\n (function () {\n var referrer = location.href;\n document.addEventListener('pjax:complete', function () {\n _paq.push(['setReferrerUrl', referrer]);\n referrer = location.href;\n _paq.push(['setCustomUrl', referrer]);\n _paq.push(['setDocumentTitle', document.title]);\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n });\n })();");
53
55
  return (0, _inferno.createVNode)(1, "script", null, null, 1, {
54
56
  "dangerouslySetInnerHTML": {
55
57
  __html: js
@@ -53,7 +53,7 @@ var OutdatedBrowser = /*#__PURE__*/function (_Component) {
53
53
  "href": cssUrl
54
54
  });
55
55
  }
56
- return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, [(0, _inferno.createVNode)(1, "h6", null, "Your browser is out-of-date!", 16), (0, _inferno.createVNode)(1, "p", null, [(0, _inferno.createTextVNode)("Update your browser to view this website correctly.&npsb;"), (0, _inferno.createVNode)(1, "a", null, [(0, _inferno.createTextVNode)("Update my browser now"), (0, _inferno.createTextVNode)(' ')], 0, {
56
+ return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, [(0, _inferno.createVNode)(1, "h6", null, "Your browser is out-of-date!", 16), (0, _inferno.createVNode)(1, "p", null, [(0, _inferno.createTextVNode)("Update your browser to view this website correctly.\xA0"), (0, _inferno.createVNode)(1, "a", null, [(0, _inferno.createTextVNode)("Update my browser now"), (0, _inferno.createTextVNode)(' ')], 0, {
57
57
  "id": "btnUpdateBrowser",
58
58
  "href": "http://outdatedbrowser.com/"
59
59
  })], 4), (0, _inferno.createVNode)(1, "p", "last", (0, _inferno.createVNode)(1, "a", null, "\xD7", 16, {
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Statcounter statistics plugin JSX component.
@@ -42,7 +44,7 @@ var Statcounter = /*#__PURE__*/function (_Component) {
42
44
  var _this$props = this.props,
43
45
  project = _this$props.project,
44
46
  security = _this$props.security;
45
- var js = "\n var sc_project=".concat(JSON.stringify(project), ";\n var sc_invisible=1;\n var sc_security=").concat(JSON.stringify(security), ";\n var sc_https=1;\n var sc_remove_link=1;");
47
+ var js = "\n var sc_project=".concat(toJs(project), ";\n var sc_invisible=1;\n var sc_security=").concat(toJs(security), ";\n var sc_https=1;\n var sc_remove_link=1;");
46
48
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "script", null, null, 1, {
47
49
  "dangerouslySetInnerHTML": {
48
50
  __html: js
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Twitter conversion tracking plugin JSX component.
@@ -40,7 +42,7 @@ var TwiterCT = /*#__PURE__*/function (_Component) {
40
42
  key: "render",
41
43
  value: function render() {
42
44
  var pixelId = this.props.pixelId;
43
- var js = "\n !function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);\n },s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='//static.ads-twitter.com/uwt.js',\n a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');\n twq('init', ".concat(JSON.stringify(pixelId), ");\n twq('track', 'PageView');\n ");
45
+ var js = "\n !function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);\n },s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='//static.ads-twitter.com/uwt.js',\n a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');\n twq('init', ".concat(toJs(pixelId), ");\n twq('track', 'PageView');\n ");
44
46
  return (0, _inferno.createVNode)(1, "script", null, null, 1, {
45
47
  "dangerouslySetInnerHTML": {
46
48
  __html: js
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ var _inferno = require("inferno");
4
+ 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); }
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
+ * Waline page view counter plugin JSX component.
19
+ * @module view/plugin/waline_pageview
20
+ */
21
+ var _require = require('inferno'),
22
+ Component = _require.Component;
23
+ var _require2 = require('../../util/cache'),
24
+ cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/script'),
26
+ toJs = _require3.toJs;
27
+
28
+ /**
29
+ * Waline page view counter plugin JSX component.
30
+ * <p>
31
+ * It counts a view of the current page, and shows the page views in the elements with the
32
+ * <code>waline-pageview-count</code> class, of the page in their <code>data-path</code> attribute, or of
33
+ * the current page without it. It counts and shows them again after switching pages with PJAX.
34
+ *
35
+ * @see https://waline.js.org/en/guide/features/pageview.html
36
+ * @example
37
+ * <WalinePageview
38
+ * serverURL="https://path/to/waline/server"
39
+ * jsUrl="/path/to/pageview.js" />
40
+ */
41
+ var WalinePageview = /*#__PURE__*/function (_Component) {
42
+ function WalinePageview() {
43
+ _classCallCheck(this, WalinePageview);
44
+ return _callSuper(this, WalinePageview, arguments);
45
+ }
46
+ _inherits(WalinePageview, _Component);
47
+ return _createClass(WalinePageview, [{
48
+ key: "render",
49
+ value: function render() {
50
+ var _this$props = this.props,
51
+ serverURL = _this$props.serverURL,
52
+ jsUrl = _this$props.jsUrl;
53
+
54
+ // Waline publishes the counter as an ES module, so load it with a dynamic import
55
+ var js = "(function () {\n var abort = null;\n function count() {\n import(".concat(toJs(jsUrl), ").then(function (Waline) {\n if (abort) {\n abort();\n }\n abort = Waline.pageviewCount({\n serverURL: ").concat(toJs(serverURL), ",\n path: window.location.pathname,\n });\n });\n }\n count();\n document.addEventListener('pjax:complete', count);\n })();");
56
+ return (0, _inferno.createVNode)(1, "script", null, null, 1, {
57
+ "dangerouslySetInnerHTML": {
58
+ __html: js
59
+ }
60
+ });
61
+ }
62
+ }]);
63
+ }(Component);
64
+ /**
65
+ * Cacheable Waline page view counter plugin JSX component.
66
+ * <p>
67
+ * This class is supposed to be used in combination with the <code>locals</code> hexo filter
68
+ * ({@link module:hexo/filter/locals}).
69
+ *
70
+ * @see module:util/cache.cacheComponent
71
+ * @example
72
+ * <WalinePageview.Cacheable
73
+ * head={false}
74
+ * plugin={{ server_url: 'https://path/to/waline/server' }}
75
+ * config={{ comment: { type: 'waline', server_url: 'https://path/to/waline/server' } }}
76
+ * helper={{ cdn: function() {...} }} />
77
+ */
78
+ WalinePageview.Cacheable = cacheComponent(WalinePageview, 'plugin.walinepageview', function (props) {
79
+ var head = props.head,
80
+ plugin = props.plugin,
81
+ config = props.config,
82
+ helper = props.helper;
83
+ if (head || !plugin) {
84
+ return null;
85
+ }
86
+ // Use the server of the Waline comments without the server_url option
87
+ var comment = config.comment;
88
+ var serverURL = _typeof(plugin) === 'object' ? plugin.server_url : null;
89
+ if (!serverURL && comment && comment.type === 'waline') {
90
+ serverURL = comment.server_url;
91
+ }
92
+ if (!serverURL) {
93
+ return null;
94
+ }
95
+ return {
96
+ serverURL: serverURL,
97
+ jsUrl: helper.cdn('@waline/client', '3.3.0', 'dist/pageview.js')
98
+ };
99
+ });
100
+ module.exports = WalinePageview;
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Algolia search engine JSX component.
@@ -69,7 +71,7 @@ var Algolia = /*#__PURE__*/function (_Component) {
69
71
  indexName: indexName,
70
72
  excerpt: excerpt
71
73
  };
72
- var js = "document.addEventListener('DOMContentLoaded', function () {\n loadAlgolia(".concat(JSON.stringify(config), ", ").concat(JSON.stringify(translation), ");\n });");
74
+ var js = "document.addEventListener('DOMContentLoaded', function () {\n loadAlgolia(".concat(toJs(config), ", ").concat(toJs(translation), ");\n });");
73
75
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "searchbox", [(0, _inferno.createVNode)(1, "div", "searchbox-mask", null, 1, {
74
76
  "style": "position:absolute;bottom:0px;left:0px;right:0px;top:0px;"
75
77
  }), (0, _inferno.createVNode)(1, "div", "searchbox-container", [(0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "div", "searchbox-input-container", null, 1, {
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Baidu search engine JSX component.
@@ -42,7 +44,7 @@ var Baidu = /*#__PURE__*/function (_Component) {
42
44
  url = _this$props.url,
43
45
  hint = _this$props.hint;
44
46
  var siteUrl = url.replace(/http(s)*:\/\//, '');
45
- var js = "(function ($) {\n $('.searchbox-input-container').on('submit', function (e) {\n var keyword = $('.searchbox-input[name=\"wd\"]').val();\n window.location = 'https://www.baidu.com/s?wd=site:".concat(siteUrl, " ' + keyword;\n return false;\n });\n })(jQuery);\n (function (document, $) {\n $(document).on('click', '.navbar-main .search', function () {\n $('.searchbox').toggleClass('show');\n }).on('click', '.searchbox .searchbox-mask', function () {\n $('.searchbox').removeClass('show');\n }).on('click', '.searchbox-close', function () {\n $('.searchbox').removeClass('show');\n });\n })(document, jQuery);");
47
+ var js = "(function ($) {\n $('.searchbox-input-container').on('submit', function (e) {\n var keyword = $('.searchbox-input[name=\"wd\"]').val();\n window.location = ".concat(toJs("https://www.baidu.com/s?wd=site:".concat(siteUrl, " ")), " + keyword;\n return false;\n });\n })(jQuery);\n (function (document, $) {\n $(document).on('click', '.navbar-main .search', function () {\n $('.searchbox').toggleClass('show');\n }).on('click', '.searchbox .searchbox-mask', function () {\n $('.searchbox').removeClass('show');\n }).on('click', '.searchbox-close', function () {\n $('.searchbox').removeClass('show');\n });\n })(document, jQuery);");
46
48
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "searchbox", [(0, _inferno.createVNode)(1, "div", "searchbox-mask", null, 1, {
47
49
  "style": "position:absolute;bottom:0px;left:0px;right:0px;top:0px;"
48
50
  }), (0, _inferno.createVNode)(1, "div", "searchbox-container", (0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "form", "searchbox-input-container", (0, _inferno.createVNode)(64, "input", "searchbox-input", null, 1, {
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Google custom search engine JSX component.
@@ -47,7 +49,7 @@ var GoogleCSE = /*#__PURE__*/function (_Component) {
47
49
  hint = _this$props.hint,
48
50
  jsUrl = _this$props.jsUrl;
49
51
  var css = '.searchbox .searchbox-body { background: white; }';
50
- var js1 = "(function() {\n var cx = '".concat(cx, "';\n var gcse = document.createElement('script');\n gcse.type = 'text/javascript';\n gcse.async = true;\n gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;\n var s = document.getElementsByTagName('script')[0];\n s.parentNode.insertBefore(gcse, s);\n })();");
52
+ var js1 = "(function() {\n var cx = ".concat(toJs(cx), ";\n var gcse = document.createElement('script');\n gcse.type = 'text/javascript';\n gcse.async = true;\n gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;\n var s = document.getElementsByTagName('script')[0];\n s.parentNode.insertBefore(gcse, s);\n })();");
51
53
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "style", null, null, 1, {
52
54
  "dangerouslySetInnerHTML": {
53
55
  __html: css
@@ -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/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Algolia search engine JSX component.
@@ -52,9 +54,9 @@ var Insight = /*#__PURE__*/function (_Component) {
52
54
  translation = _this$props.translation,
53
55
  contentUrl = _this$props.contentUrl,
54
56
  jsUrl = _this$props.jsUrl;
55
- var js = "document.addEventListener('DOMContentLoaded', function () {\n loadInsight(".concat(JSON.stringify({
57
+ var js = "document.addEventListener('DOMContentLoaded', function () {\n loadInsight(".concat(toJs({
56
58
  contentUrl: contentUrl
57
- }), ", ").concat(JSON.stringify(translation), ");\n });");
59
+ }), ", ").concat(toJs(translation), ");\n });");
58
60
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "searchbox", (0, _inferno.createVNode)(1, "div", "searchbox-container", [(0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "div", "searchbox-input-container", (0, _inferno.createVNode)(64, "input", "searchbox-input", null, 1, {
59
61
  "type": "text",
60
62
  "placeholder": translation.hint
@@ -22,10 +22,13 @@ 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
  * AddThis share buttons JSX component.
28
30
  *
31
+ * @deprecated AddThis shut down on May 31, 2023. Use AddToAny or ShareThis instead.
29
32
  * @see https://www.addthis.com/dashboard
30
33
  * @example
31
34
  * <AddThis installUrl="******" />
@@ -39,6 +42,7 @@ var AddThis = /*#__PURE__*/function (_Component) {
39
42
  return _createClass(AddThis, [{
40
43
  key: "render",
41
44
  value: function render() {
45
+ deprecate('share.addthis', 'AddThis shut down on May 31, 2023. Use AddToAny or ShareThis instead.');
42
46
  var installUrl = this.props.installUrl;
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 AddThis. Please set it in"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
@@ -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
  * Convert a Hexo language code into a Moment.js locale name.
@@ -70,12 +85,18 @@ var Archives = /*#__PURE__*/function (_Component) {
70
85
  var _this$props = this.props,
71
86
  items = _this$props.items,
72
87
  title = _this$props.title,
73
- showCount = _this$props.showCount;
74
- 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", items.map(function (archive) {
88
+ showCount = _this$props.showCount,
89
+ moreUrl = _this$props.moreUrl,
90
+ moreTitle = _this$props.moreTitle;
91
+ 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", [items.map(function (archive) {
75
92
  return (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", archive.name, 0), 2), showCount ? (0, _inferno.createVNode)(1, "span", "level-end", (0, _inferno.createVNode)(1, "span", "level-item tag", archive.count, 0), 2) : null], 0, {
76
93
  "href": archive.url
77
94
  }), 2);
78
- }), 0)], 4), 2), 2, {
95
+ }), 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, {
96
+ "aria-hidden": "true"
97
+ }), 2)], 4, {
98
+ "href": moreUrl
99
+ }), 2) : null], 0)], 4), 2), 2, {
79
100
  "data-type": "archives"
80
101
  });
81
102
  }
@@ -120,12 +141,14 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', function (props
120
141
  group_by = _widget$group_by === void 0 ? 'monthly' : _widget$group_by,
121
142
  _widget$order = widget.order,
122
143
  order = _widget$order === void 0 ? -1 : _widget$order,
123
- _widget$showCount = widget.showCount,
124
- showCount = _widget$showCount === void 0 ? true : _widget$showCount,
125
144
  _widget$format = widget.format,
126
- format = _widget$format === void 0 ? null : _widget$format;
145
+ format = _widget$format === void 0 ? null : _widget$format,
146
+ amount = widget.amount;
147
+ // show_count, like the tags widget, or showCount, which this widget used to read
148
+ var showCount = firstSet(widget.show_count, widget.showCount, true);
127
149
  var url_for = helper.url_for,
128
- _p = helper._p;
150
+ _p = helper._p,
151
+ __ = helper.__;
129
152
  var posts = site.posts.sort('date', order);
130
153
  if (!posts.length) {
131
154
  return null;
@@ -165,8 +188,11 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', function (props
165
188
  }
166
189
  return url_for(url);
167
190
  };
191
+
192
+ // Link to the archive page when some of the archives are not shown
193
+ var hasMore = amount > 0 && data.length > amount;
168
194
  return {
169
- items: data.map(function (item) {
195
+ items: (hasMore ? data.slice(0, amount) : data).map(function (item) {
170
196
  return {
171
197
  name: item.name,
172
198
  count: item.count,
@@ -174,7 +200,9 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', function (props
174
200
  };
175
201
  }),
176
202
  title: _p('common.archive', Infinity),
177
- showCount: showCount
203
+ showCount: showCount,
204
+ moreUrl: hasMore ? url_for("".concat(config.archive_dir, "/")) : null,
205
+ moreTitle: translate(__, 'widget.more', 'More')
178
206
  };
179
207
  });
180
208
  module.exports = Archives;