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
@@ -2,9 +2,6 @@
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; }
8
5
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
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); } }
10
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -25,6 +22,11 @@ var _require = require('inferno'),
25
22
  Component = _require.Component;
26
23
  var _require2 = require('../../util/cache'),
27
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/script'),
26
+ appendScript = _require3.appendScript,
27
+ toJs = _require3.toJs;
28
+ var _require4 = require('../../util/appearance'),
29
+ isDark = _require4.isDark;
28
30
 
29
31
  /**
30
32
  * Giscus comment JSX component.
@@ -42,6 +44,7 @@ var _require2 = require('../../util/cache'),
42
44
  * emitMetadata={0}
43
45
  * inputPosition="******"
44
46
  * theme="******"
47
+ * darkTheme="******"
45
48
  * lang="******"
46
49
  * lazy="******" />
47
50
  */
@@ -66,6 +69,7 @@ var Giscus = /*#__PURE__*/function (_Component) {
66
69
  emitMetadata = _this$props.emitMetadata,
67
70
  inputPosition = _this$props.inputPosition,
68
71
  theme = _this$props.theme,
72
+ darkTheme = _this$props.darkTheme,
69
73
  customThemeCss = _this$props.customThemeCss,
70
74
  lang = _this$props.lang,
71
75
  lazy = _this$props.lazy;
@@ -75,9 +79,7 @@ var Giscus = /*#__PURE__*/function (_Component) {
75
79
  if ((mapping === 'specific' || mapping === 'number') && !term) {
76
80
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You set "), (0, _inferno.createVNode)(1, "code", null, "mapping", 16), (0, _inferno.createTextVNode)(" to "), (0, _inferno.createVNode)(1, "code", null, "specific", 16), (0, _inferno.createTextVNode)(" or "), (0, _inferno.createVNode)(1, "code", null, "number", 16), (0, _inferno.createTextVNode)(", but did not set "), (0, _inferno.createVNode)(1, "code", null, "term", 16), (0, _inferno.createTextVNode)(" for Giscus. Please set "), (0, _inferno.createVNode)(1, "code", null, "term", 16), (0, _inferno.createTextVNode)(" in "), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 4);
77
81
  }
78
- var config = {
79
- repo: repo
80
- };
82
+ var config = {};
81
83
  config['data-repo'] = repo;
82
84
  config['data-repo-id'] = repoId;
83
85
  config['data-category-id'] = categoryId;
@@ -91,6 +93,9 @@ var Giscus = /*#__PURE__*/function (_Component) {
91
93
  } else {
92
94
  config['data-mapping'] = 'pathname';
93
95
  }
96
+ if (term) {
97
+ config['data-term'] = term;
98
+ }
94
99
  if (strict) {
95
100
  config['data-strict'] = 1;
96
101
  } else {
@@ -111,18 +116,16 @@ var Giscus = /*#__PURE__*/function (_Component) {
111
116
  } else {
112
117
  config['data-input-position'] = 'top';
113
118
  }
114
- if (theme) {
115
- if (theme === 'custom') {
116
- if (customThemeCss) {
117
- config['data-theme'] = customThemeCss;
118
- } else {
119
- return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You set "), (0, _inferno.createVNode)(1, "code", null, "theme", 16), (0, _inferno.createTextVNode)(" to "), (0, _inferno.createVNode)(1, "code", null, "custom", 16), (0, _inferno.createTextVNode)(", but did not apply a"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "customThemeCss", 16), (0, _inferno.createTextVNode)(" for Giscus. Please set it in "), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
120
- }
119
+ // Use the dark theme when the page looks dark, unless the theme is custom
120
+ var dynamicConfig = {};
121
+ if (theme === 'custom') {
122
+ if (customThemeCss) {
123
+ config['data-theme'] = customThemeCss;
121
124
  } else {
122
- config['data-theme'] = theme;
125
+ return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You set "), (0, _inferno.createVNode)(1, "code", null, "theme", 16), (0, _inferno.createTextVNode)(" to "), (0, _inferno.createVNode)(1, "code", null, "custom", 16), (0, _inferno.createTextVNode)(", but did not apply a"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "customThemeCss", 16), (0, _inferno.createTextVNode)(" for Giscus. Please set it in "), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
123
126
  }
124
127
  } else {
125
- config['data-theme'] = 'noborder_light';
128
+ dynamicConfig['data-theme'] = "".concat(isDark(), " ? ").concat(toJs(darkTheme || 'noborder_dark'), " : ").concat(toJs(theme || 'noborder_light'));
126
129
  }
127
130
  if (lang) {
128
131
  config['data-lang'] = lang;
@@ -132,12 +135,17 @@ var Giscus = /*#__PURE__*/function (_Component) {
132
135
  if (lazy) {
133
136
  config['data-loading'] = 'lazy';
134
137
  }
135
- return (0, _inferno.normalizeProps)((0, _inferno.createVNode)(1, "script", null, null, 1, _objectSpread(_objectSpread({
136
- "src": "https://giscus.app/client.js"
137
- }, config), {}, {
138
- "crossorigin": "anonymous",
139
- "async": true
140
- })));
138
+ config.crossorigin = 'anonymous';
139
+ // Giscus puts its iframe into the element with the giscus class, so add its script to <head> to
140
+ // keep the number of scripts in the comment section the same for PJAX
141
+ var js = appendScript('head', 'https://giscus.app/client.js', config, dynamicConfig);
142
+ return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "giscus", null, 1, {
143
+ "id": "giscus-thread"
144
+ }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
145
+ "dangerouslySetInnerHTML": {
146
+ __html: js
147
+ }
148
+ })], 4);
141
149
  }
142
150
  }]);
143
151
  }(Component);
@@ -161,6 +169,7 @@ var Giscus = /*#__PURE__*/function (_Component) {
161
169
  * emitMetadata: {false}
162
170
  * inputPosition: "******"
163
171
  * theme: "******"
172
+ * darkTheme: "******"
164
173
  * lang: "******"
165
174
  * lazy: "******"
166
175
  * }} />
@@ -178,6 +187,7 @@ Giscus.Cacheable = cacheComponent(Giscus, 'comment.giscus', function (props) {
178
187
  emitMetadata = _props$comment.emitMetadata,
179
188
  inputPosition = _props$comment.inputPosition,
180
189
  theme = _props$comment.theme,
190
+ darkTheme = _props$comment.darkTheme,
181
191
  customThemeCss = _props$comment.customThemeCss,
182
192
  lang = _props$comment.lang,
183
193
  lazy = _props$comment.lazy;
@@ -193,6 +203,7 @@ Giscus.Cacheable = cacheComponent(Giscus, 'comment.giscus', function (props) {
193
203
  emitMetadata: emitMetadata,
194
204
  inputPosition: inputPosition,
195
205
  theme: theme,
206
+ darkTheme: darkTheme,
196
207
  customThemeCss: customThemeCss,
197
208
  lang: lang,
198
209
  lazy: lazy
@@ -24,6 +24,7 @@ var _require = require('inferno'),
24
24
  var _require2 = require('../../util/cache'),
25
25
  cacheComponent = _require2.cacheComponent;
26
26
  var loadScripts = require('../../util/script');
27
+ var toJs = loadScripts.toJs;
27
28
 
28
29
  /**
29
30
  * Gitalk comment JSX component.
@@ -74,14 +75,15 @@ var Gitalk = /*#__PURE__*/function (_Component) {
74
75
  perPage = _this$props$perPage === void 0 ? 10 : _this$props$perPage,
75
76
  proxy = _this$props.proxy,
76
77
  flipMoveOptions = _this$props.flipMoveOptions,
77
- enableHotKey = _this$props.enableHotKey,
78
+ _this$props$enableHot = _this$props.enableHotKey,
79
+ enableHotKey = _this$props$enableHot === void 0 ? true : _this$props$enableHot,
78
80
  language = _this$props.language,
79
81
  jsUrl = _this$props.jsUrl,
80
82
  cssUrl = _this$props.cssUrl;
81
83
  if (!id || !repo || !owner || !admin || !clientId || !clientSecret) {
82
84
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "owner", 16), (0, _inferno.createTextVNode)(", "), (0, _inferno.createVNode)(1, "code", null, "admin", 16), (0, _inferno.createTextVNode)(", "), (0, _inferno.createVNode)(1, "code", null, "repo", 16), (0, _inferno.createTextVNode)(","), (0, _inferno.createVNode)(1, "code", null, "client_id", 16), (0, _inferno.createTextVNode)(", or "), (0, _inferno.createVNode)(1, "code", null, "client_secret", 16), (0, _inferno.createTextVNode)(" for Gitalk. Please set it in"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
83
85
  }
84
- var js = "var gitalk = new Gitalk({\n id: ".concat(JSON.stringify(id), ",\n repo: ").concat(JSON.stringify(repo), ",\n owner: ").concat(JSON.stringify(owner), ",\n clientID: ").concat(JSON.stringify(clientId), ",\n clientSecret: ").concat(JSON.stringify(clientSecret), ",\n admin: ").concat(JSON.stringify(admin), ",\n createIssueManually: ").concat(!!createIssueManually, ",\n distractionFreeMode: ").concat(!!distractionFreeMode, ",\n perPage: ").concat(JSON.stringify(perPage), ",\n pagerDirection: ").concat(JSON.stringify(pagerDirection), ",\n ").concat(proxy ? "proxy: ".concat(JSON.stringify(proxy), ",") : '', "\n ").concat(flipMoveOptions ? "flipMoveOptions: ".concat(JSON.stringify(flipMoveOptions), ",") : '', "\n enableHotKey: ").concat(enableHotKey ? !!enableHotKey : true, ",\n ").concat(language ? "language: ".concat(JSON.stringify(language), ",") : '', "\n })\n gitalk.render('comment-container')");
86
+ var js = "var gitalk = new Gitalk({\n id: ".concat(toJs(id), ",\n repo: ").concat(toJs(repo), ",\n owner: ").concat(toJs(owner), ",\n clientID: ").concat(toJs(clientId), ",\n clientSecret: ").concat(toJs(clientSecret), ",\n admin: ").concat(toJs(admin), ",\n createIssueManually: ").concat(!!createIssueManually, ",\n distractionFreeMode: ").concat(!!distractionFreeMode, ",\n perPage: ").concat(toJs(perPage), ",\n pagerDirection: ").concat(toJs(pagerDirection), ",\n ").concat(proxy ? "proxy: ".concat(toJs(proxy), ",") : '', "\n ").concat(flipMoveOptions ? "flipMoveOptions: ".concat(toJs(flipMoveOptions), ",") : '', "\n enableHotKey: ").concat(!!enableHotKey, ",\n ").concat(language ? "language: ".concat(toJs(language), ",") : '', "\n })\n gitalk.render('comment-container')");
85
87
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, null, 1, {
86
88
  "id": "comment-container"
87
89
  }), (0, _inferno.createVNode)(1, "link", null, null, 1, {
@@ -25,11 +25,15 @@ var _require = require('inferno'),
25
25
  var _require2 = require('../../util/cache'),
26
26
  cacheComponent = _require2.cacheComponent;
27
27
  var loadScripts = require('../../util/script');
28
+ var toJs = loadScripts.toJs;
29
+ var _require3 = require('../../util/deprecate'),
30
+ deprecate = _require3.deprecate;
28
31
 
29
32
  /**
30
33
  * Gitment comment JSX component.
31
34
  *
32
- * @deprecated
35
+ * @deprecated Gitment is no longer maintained, and the GitHub sign-in proxy it uses no longer works. Use
36
+ * Giscus, Utterances or Gitalk instead.
33
37
  * @see https://github.com/imsun/gitment
34
38
  * @example
35
39
  * <Gitment
@@ -50,6 +54,7 @@ var Gitment = /*#__PURE__*/function (_Component) {
50
54
  return _createClass(Gitment, [{
51
55
  key: "render",
52
56
  value: function render() {
57
+ deprecate('comment.gitment', 'Gitment is no longer maintained, and the GitHub sign-in proxy it uses no longer works. Use Giscus, Utterances or Gitalk instead.');
53
58
  var _this$props = this.props,
54
59
  id = _this$props.id,
55
60
  repo = _this$props.repo,
@@ -63,7 +68,7 @@ var Gitment = /*#__PURE__*/function (_Component) {
63
68
  if (!id || !repo || !owner || !clientId || !clientSecret) {
64
69
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "owner", 16), (0, _inferno.createTextVNode)(", "), (0, _inferno.createVNode)(1, "code", null, "repo", 16), (0, _inferno.createTextVNode)(", "), (0, _inferno.createVNode)(1, "code", null, "clientId", 16), (0, _inferno.createTextVNode)(", or"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "clientSecret", 16), (0, _inferno.createTextVNode)(" for Gitment. Please set it in "), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
65
70
  }
66
- var js = "var gitment = new Gitment({\n id: '".concat(id, "',\n repo: '").concat(repo, "',\n owner: '").concat(owner, "',\n oauth: {\n client_id: '").concat(clientId, "',\n client_secret: '").concat(clientSecret, "',\n },\n perPage: ").concat(perPage, ",\n maxCommentHeight: ").concat(maxCommentHeight, "\n })\n gitment.render('comment-container')");
71
+ var js = "var gitment = new Gitment({\n id: ".concat(toJs(id), ",\n repo: ").concat(toJs(repo), ",\n owner: ").concat(toJs(owner), ",\n oauth: {\n client_id: ").concat(toJs(clientId), ",\n client_secret: ").concat(toJs(clientSecret), ",\n },\n perPage: ").concat(toJs(perPage), ",\n maxCommentHeight: ").concat(toJs(maxCommentHeight), "\n })\n gitment.render('comment-container')");
67
72
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, null, 1, {
68
73
  "id": "comment-container"
69
74
  }), (0, _inferno.createVNode)(1, "link", null, 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
  * Isso comment JSX component.
@@ -43,9 +45,11 @@ var Isso = /*#__PURE__*/function (_Component) {
43
45
  if (!url) {
44
46
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "url", 16), (0, _inferno.createTextVNode)(" for Isso. Please set it in "), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 4);
45
47
  }
48
+ // The URL can be given with or without the protocol
49
+ var host = url.replace(/^(https?:)?\/\//i, '').replace(/\/+$/, '');
46
50
  // Isso renders the thread as soon as its script runs, so add a new script every time this code
47
51
  // runs (e.g., again by PJAX after switching pages) instead of loading it only once.
48
- var js = "(function () {\n var script = document.createElement('script');\n script.src = ".concat(JSON.stringify("//".concat(url, "/js/embed.min.js")), ";\n script.async = true;\n script.setAttribute('data-isso', ").concat(JSON.stringify('//' + url), ");\n document.head.appendChild(script);\n })();");
52
+ var js = "(function () {\n var script = document.createElement('script');\n script.src = ".concat(toJs("//".concat(host, "/js/embed.min.js")), ";\n script.async = true;\n script.setAttribute('data-isso', ").concat(toJs('//' + host), ");\n document.head.appendChild(script);\n })();");
49
53
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, null, 1, {
50
54
  "id": "isso-thread"
51
55
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
@@ -24,6 +24,7 @@ var _require = require('inferno'),
24
24
  var _require2 = require('../../util/cache'),
25
25
  cacheComponent = _require2.cacheComponent;
26
26
  var loadScripts = require('../../util/script');
27
+ var toJs = loadScripts.toJs;
27
28
 
28
29
  /**
29
30
  * Twikoo comment JSX component.
@@ -50,7 +51,10 @@ var Twikoo = /*#__PURE__*/function (_Component) {
50
51
  region = _this$props.region,
51
52
  lang = _this$props.lang,
52
53
  jsUrl = _this$props.jsUrl;
53
- var js = "twikoo.init({\n envId: '".concat(envId, "',\n ").concat(region ? "region: ".concat(JSON.stringify(region), ",") : '', "\n ").concat(lang ? "lang: ".concat(JSON.stringify(lang), ",") : '', "\n });");
54
+ if (!envId) {
55
+ return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "env_id", 16), (0, _inferno.createTextVNode)(" for Twikoo. Please set it in"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
56
+ }
57
+ var js = "twikoo.init({\n envId: ".concat(toJs(envId), ",\n ").concat(region ? "region: ".concat(toJs(region), ",") : '', "\n ").concat(lang ? "lang: ".concat(toJs(lang), ",") : '', "\n });");
54
58
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "content twikoo", null, 1, {
55
59
  "id": "twikoo"
56
60
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
@@ -2,9 +2,6 @@
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; }
8
5
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
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); } }
10
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -25,6 +22,11 @@ var _require = require('inferno'),
25
22
  Component = _require.Component;
26
23
  var _require2 = require('../../util/cache'),
27
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/script'),
26
+ appendScript = _require3.appendScript,
27
+ toJs = _require3.toJs;
28
+ var _require4 = require('../../util/appearance'),
29
+ isDark = _require4.isDark;
28
30
 
29
31
  /**
30
32
  * Utterances comment JSX component.
@@ -36,7 +38,8 @@ var _require2 = require('../../util/cache'),
36
38
  * issueTerm="******"
37
39
  * issueNumber={123}
38
40
  * label="******"
39
- * theme="******" />
41
+ * theme="******"
42
+ * darkTheme="******" />
40
43
  */
41
44
  var Utterances = /*#__PURE__*/function (_Component) {
42
45
  function Utterances() {
@@ -52,7 +55,8 @@ var Utterances = /*#__PURE__*/function (_Component) {
52
55
  issueTerm = _this$props.issueTerm,
53
56
  issueNumber = _this$props.issueNumber,
54
57
  label = _this$props.label,
55
- theme = _this$props.theme;
58
+ theme = _this$props.theme,
59
+ darkTheme = _this$props.darkTheme;
56
60
  if (!repo || !issueTerm && !issueNumber) {
57
61
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "repo", 16), (0, _inferno.createTextVNode)(", "), (0, _inferno.createVNode)(1, "code", null, "issue_term", 16), (0, _inferno.createTextVNode)(", or"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "issue_number", 16), (0, _inferno.createTextVNode)(" for Utterances. Please set it in "), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
58
62
  }
@@ -67,15 +71,18 @@ var Utterances = /*#__PURE__*/function (_Component) {
67
71
  if (label) {
68
72
  config.label = label;
69
73
  }
70
- if (theme) {
71
- config.theme = theme;
72
- }
73
- return (0, _inferno.normalizeProps)((0, _inferno.createVNode)(1, "script", null, null, 1, _objectSpread(_objectSpread({
74
- "src": "https://utteranc.es/client.js"
75
- }, config), {}, {
76
- "crossorigin": "anonymous",
77
- "async": true
78
- })));
74
+ config.crossorigin = 'anonymous';
75
+ // Use the dark theme when the page looks dark
76
+ var js = appendScript('#utterances-thread', 'https://utteranc.es/client.js', config, {
77
+ theme: "".concat(isDark(), " ? ").concat(toJs(darkTheme || 'github-dark'), " : ").concat(toJs(theme || 'github-light'))
78
+ });
79
+ return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, null, 1, {
80
+ "id": "utterances-thread"
81
+ }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
82
+ "dangerouslySetInnerHTML": {
83
+ __html: js
84
+ }
85
+ })], 4);
79
86
  }
80
87
  }]);
81
88
  }(Component);
@@ -94,6 +101,7 @@ var Utterances = /*#__PURE__*/function (_Component) {
94
101
  * issue_number: {123}
95
102
  * label: "******"
96
103
  * theme: "******"
104
+ * dark_theme: "******"
97
105
  * }} />
98
106
  */
99
107
  Utterances.Cacheable = cacheComponent(Utterances, 'comment.utterances', function (props) {
@@ -102,13 +110,15 @@ Utterances.Cacheable = cacheComponent(Utterances, 'comment.utterances', function
102
110
  issue_term = _props$comment.issue_term,
103
111
  issue_number = _props$comment.issue_number,
104
112
  label = _props$comment.label,
105
- theme = _props$comment.theme;
113
+ theme = _props$comment.theme,
114
+ dark_theme = _props$comment.dark_theme;
106
115
  return {
107
116
  repo: repo,
108
117
  issueTerm: issue_term,
109
118
  issueNumber: issue_number,
110
119
  label: label,
111
- theme: theme
120
+ theme: theme,
121
+ darkTheme: dark_theme
112
122
  };
113
123
  });
114
124
  module.exports = Utterances;
@@ -23,10 +23,15 @@ var _require = require('inferno'),
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
25
  var loadScripts = require('../../util/script');
26
+ var toJs = loadScripts.toJs;
27
+ var _require3 = require('../../util/deprecate'),
28
+ deprecate = _require3.deprecate;
26
29
 
27
30
  /**
28
31
  * Valine comment JSX component.
29
32
  *
33
+ * @deprecated LeanCloud, where Valine stores the comments, shuts down on January 12, 2027. Use Waline,
34
+ * Twikoo or another comment system instead.
30
35
  * @see https://valine.js.org/quickstart.html
31
36
  * @example
32
37
  * <Valine
@@ -57,6 +62,7 @@ var Valine = /*#__PURE__*/function (_Component) {
57
62
  return _createClass(Valine, [{
58
63
  key: "render",
59
64
  value: function render() {
65
+ deprecate('comment.valine', 'LeanCloud, where Valine stores the comments, shuts down on January 12, 2027. Use Waline, Twikoo or another comment system instead.');
60
66
  var _this$props = this.props,
61
67
  appId = _this$props.appId,
62
68
  appKey = _this$props.appKey,
@@ -91,7 +97,7 @@ var Valine = /*#__PURE__*/function (_Component) {
91
97
  if (!appId || !appKey) {
92
98
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "app_id", 16), (0, _inferno.createTextVNode)(" or "), (0, _inferno.createVNode)(1, "code", null, "app_key", 16), (0, _inferno.createTextVNode)(" for Valine. Please set it in "), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 4);
93
99
  }
94
- var js = "new Valine({\n el: '#valine-thread',\n appId: ".concat(JSON.stringify(appId), ",\n appKey: ").concat(JSON.stringify(appKey), ",\n ").concat(placeholder ? "placeholder: ".concat(JSON.stringify(placeholder), ",") : '', "\n ").concat(avatar ? "avatar: ".concat(JSON.stringify(avatar), ",") : '', "\n ", "avatarForce: ".concat(JSON.stringify(avatarForce), ","), "\n ").concat(meta ? "meta: ".concat(JSON.stringify(meta), ",") : '', "\n ").concat(pageSize ? "pageSize: ".concat(JSON.stringify(pageSize), ",") : '', "\n ").concat(lang ? "lang: ".concat(JSON.stringify(lang), ",") : '', "\n ", "visitor: ".concat(JSON.stringify(visitor), ","), "\n ", "highlight: ".concat(JSON.stringify(highlight), ","), "\n ", "recordIP: ".concat(JSON.stringify(recordIP), ","), "\n ").concat(serverURLs ? "serverURLs: ".concat(JSON.stringify(serverURLs), ",") : '', "\n ").concat(emojiCDN ? "emojiCDN: ".concat(JSON.stringify(emojiCDN), ",") : '', "\n ").concat(emojiMaps ? "emojiMaps: ".concat(JSON.stringify(emojiMaps), ",") : '', "\n ", "enableQQ: ".concat(JSON.stringify(enableQQ), ","), "\n ").concat(Array.isArray(fields) ? "requiredFields: ".concat(JSON.stringify(fields), ",") : '', "\n });");
100
+ var js = "new Valine({\n el: '#valine-thread',\n appId: ".concat(toJs(appId), ",\n appKey: ").concat(toJs(appKey), ",\n ").concat(placeholder ? "placeholder: ".concat(toJs(placeholder), ",") : '', "\n ").concat(avatar ? "avatar: ".concat(toJs(avatar), ",") : '', "\n ", "avatarForce: ".concat(toJs(avatarForce), ","), "\n ").concat(meta ? "meta: ".concat(toJs(meta), ",") : '', "\n ").concat(pageSize ? "pageSize: ".concat(toJs(pageSize), ",") : '', "\n ").concat(lang ? "lang: ".concat(toJs(lang), ",") : '', "\n ", "visitor: ".concat(toJs(visitor), ","), "\n ", "highlight: ".concat(toJs(highlight), ","), "\n ", "recordIP: ".concat(toJs(recordIP), ","), "\n ").concat(serverURLs ? "serverURLs: ".concat(toJs(serverURLs), ",") : '', "\n ").concat(emojiCDN ? "emojiCDN: ".concat(toJs(emojiCDN), ",") : '', "\n ").concat(emojiMaps ? "emojiMaps: ".concat(toJs(emojiMaps), ",") : '', "\n ", "enableQQ: ".concat(toJs(enableQQ), ","), "\n ").concat(Array.isArray(fields) ? "requiredFields: ".concat(toJs(fields), ",") : '', "\n });");
95
101
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "content", null, 1, {
96
102
  "id": "valine-thread"
97
103
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
@@ -22,6 +22,10 @@ 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;
27
+ var _require4 = require('../../util/appearance'),
28
+ getAppearance = _require4.getAppearance;
25
29
 
26
30
  /**
27
31
  * Waline comment JSX component.
@@ -61,15 +65,13 @@ var Waline = /*#__PURE__*/function (_Component) {
61
65
  value: function render() {
62
66
  var _this$props = this.props,
63
67
  serverURL = _this$props.serverURL,
64
- _this$props$path = _this$props.path,
65
- path = _this$props$path === void 0 ? 'window.location.pathname' : _this$props$path,
68
+ path = _this$props.path,
66
69
  _this$props$lang = _this$props.lang,
67
70
  lang = _this$props$lang === void 0 ? 'zh-CN' : _this$props$lang,
68
71
  locale = _this$props.locale,
69
72
  _this$props$emoji = _this$props.emoji,
70
73
  emoji = _this$props$emoji === void 0 ? ['https://cdn.jsdelivr.net/gh/walinejs/emojis/weibo'] : _this$props$emoji,
71
- _this$props$dark = _this$props.dark,
72
- dark = _this$props$dark === void 0 ? '' : _this$props$dark,
74
+ dark = _this$props.dark,
73
75
  _this$props$meta = _this$props.meta,
74
76
  meta = _this$props$meta === void 0 ? ['nick', 'mail', 'link'] : _this$props$meta,
75
77
  _this$props$requiredM = _this$props.requiredMeta,
@@ -80,14 +82,10 @@ var Waline = /*#__PURE__*/function (_Component) {
80
82
  wordLimit = _this$props$wordLimit === void 0 ? 0 : _this$props$wordLimit,
81
83
  _this$props$pageSize = _this$props.pageSize,
82
84
  pageSize = _this$props$pageSize === void 0 ? 10 : _this$props$pageSize,
83
- _this$props$imageUplo = _this$props.imageUploader,
84
- imageUploader = _this$props$imageUplo === void 0 ? false : _this$props$imageUplo,
85
- _this$props$highlight = _this$props.highlighter,
86
- highlighter = _this$props$highlight === void 0 ? false : _this$props$highlight,
87
- _this$props$texRender = _this$props.texRenderer,
88
- texRenderer = _this$props$texRender === void 0 ? false : _this$props$texRender,
89
- _this$props$search = _this$props.search,
90
- search = _this$props$search === void 0 ? false : _this$props$search,
85
+ imageUploader = _this$props.imageUploader,
86
+ highlighter = _this$props.highlighter,
87
+ texRenderer = _this$props.texRenderer,
88
+ search = _this$props.search,
91
89
  _this$props$pageview = _this$props.pageview,
92
90
  pageview = _this$props$pageview === void 0 ? false : _this$props$pageview,
93
91
  _this$props$comment = _this$props.comment,
@@ -99,7 +97,18 @@ var Waline = /*#__PURE__*/function (_Component) {
99
97
  if (!serverURL) {
100
98
  return (0, _inferno.createVNode)(1, "div", "notification is-danger", [(0, _inferno.createTextVNode)("You forgot to set the "), (0, _inferno.createVNode)(1, "code", null, "server_url", 16), (0, _inferno.createTextVNode)(" for Waline. Please set it in"), (0, _inferno.createTextVNode)(' '), (0, _inferno.createVNode)(1, "code", null, "_config.yml", 16), (0, _inferno.createTextVNode)(".")], 0);
101
99
  }
102
- var js = "import { init } from \"".concat(jsUrl, "\";\n init({\n el: '#waline-thread',\n serverURL: ").concat(JSON.stringify(serverURL), ",\n path: ").concat(path, ",\n ").concat(lang ? "lang: ".concat(JSON.stringify(lang), ",") : '', "\n ").concat(locale ? "locale: ".concat(JSON.stringify(locale), ",") : '', "\n ").concat(emoji ? "emoji: ".concat(JSON.stringify(emoji), ",") : '', "\n ").concat(dark ? "dark: ".concat(JSON.stringify(dark), ",") : '', "\n ").concat(meta ? "meta: ".concat(JSON.stringify(meta), ",") : '', "\n ").concat(Array.isArray(requiredMeta) ? "requiredMeta: ".concat(JSON.stringify(requiredMeta), ",") : '', "\n ").concat(login ? "login: ".concat(JSON.stringify(login), ",") : '', "\n ").concat(wordLimit ? "wordLimit: ".concat(JSON.stringify(wordLimit), ",") : '', "\n ").concat(pageSize ? "pageSize: ".concat(JSON.stringify(pageSize), ",") : '', "\n ").concat(imageUploader === false ? "imageUploader: false," : '', "\n ").concat(highlighter === false ? "highlighter: false," : '', "\n ").concat(texRenderer === false ? "texRenderer: false," : '', "\n ").concat(search === false ? "search: false," : '', "\n ").concat(typeof pageview !== 'undefined' ? "pageview: ".concat(JSON.stringify(pageview), ",") : '', "\n ").concat(typeof comment !== 'undefined' ? "comment: ".concat(JSON.stringify(comment), ",") : '', "\n ", "copyright: ".concat(JSON.stringify(copyright), ","), "\n });");
100
+ // Without the dark option, follow the appearance of the page: the system color scheme for the auto
101
+ // appearance, or the data-appearance="dark" attribute of <html> otherwise
102
+ var darkOption = dark === null || typeof dark === 'undefined' || dark === '' ? "".concat(getAppearance(), " === 'auto' ? 'auto' : 'html[data-appearance=\"dark\"]'") : toJs(dark);
103
+ // A path, such as /posts/hello/, or a JavaScript expression, such as window.location.pathname
104
+ var pathCode = path || 'window.location.pathname';
105
+ if (pathCode.startsWith('/')) {
106
+ pathCode = toJs(pathCode);
107
+ }
108
+ // Use a classic script with a dynamic import instead of a module script, so that PJAX, which only
109
+ // runs classic scripts, initializes Waline again after switching pages. The previous instance,
110
+ // whose element PJAX has replaced, is destroyed first.
111
+ var js = "import(".concat(toJs(jsUrl), ").then(function (Waline) {\n if (window.__walineInstance) {\n window.__walineInstance.destroy();\n }\n window.__walineInstance = Waline.init({\n el: '#waline-thread',\n serverURL: ").concat(toJs(serverURL), ",\n path: ").concat(pathCode, ",\n ").concat(lang ? "lang: ".concat(toJs(lang), ",") : '', "\n ").concat(locale ? "locale: ".concat(toJs(locale), ",") : '', "\n ").concat(emoji ? "emoji: ".concat(toJs(emoji), ",") : '', "\n dark: ").concat(darkOption, ",\n ").concat(meta ? "meta: ".concat(toJs(meta), ",") : '', "\n ").concat(Array.isArray(requiredMeta) ? "requiredMeta: ".concat(toJs(requiredMeta), ",") : '', "\n ").concat(login ? "login: ".concat(toJs(login), ",") : '', "\n ").concat(wordLimit ? "wordLimit: ".concat(toJs(wordLimit), ",") : '', "\n ").concat(pageSize ? "pageSize: ".concat(toJs(pageSize), ",") : '', "\n ").concat(imageUploader === false ? "imageUploader: false," : '', "\n ").concat(highlighter === false ? "highlighter: false," : '', "\n ").concat(texRenderer === false ? "texRenderer: false," : '', "\n ").concat(search === false ? "search: false," : '', "\n ").concat(typeof pageview !== 'undefined' ? "pageview: ".concat(toJs(pageview), ",") : '', "\n ").concat(typeof comment !== 'undefined' ? "comment: ".concat(toJs(comment), ",") : '', "\n ", "copyright: ".concat(toJs(copyright), ","), "\n });\n });");
103
112
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "content", null, 1, {
104
113
  "id": "waline-thread"
105
114
  }), (0, _inferno.createVNode)(1, "link", null, null, 1, {
@@ -108,7 +117,6 @@ var Waline = /*#__PURE__*/function (_Component) {
108
117
  "media": "print",
109
118
  "onload": "this.media='all'"
110
119
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
111
- "type": "module",
112
120
  "dangerouslySetInnerHTML": {
113
121
  __html: js
114
122
  }
@@ -137,10 +145,10 @@ var Waline = /*#__PURE__*/function (_Component) {
137
145
  * login: false,
138
146
  * word_limit: 0,
139
147
  * page_size: 10,
140
- * image_uploader: true,
141
- * highlighter: true,
148
+ * image_uploader: false,
149
+ * highlighter: false,
142
150
  * tex_renderer: false,
143
- * search: true,
151
+ * search: false,
144
152
  * pageview: false,
145
153
  * comment: false,
146
154
  * copyright: true,
@@ -164,10 +172,12 @@ Waline.Cacheable = cacheComponent(Waline, 'comment.waline', function (props) {
164
172
  login: comment.login,
165
173
  wordLimit: comment.word_limit,
166
174
  pageSize: comment.page_size,
167
- imageUploader: comment.image_uploader,
168
- highlighter: comment.highlighter,
169
- texRenderer: comment.tex_renderer,
170
- search: comment.search,
175
+ // These options of the theme config disable the features when they are true, which Waline does
176
+ // when its options are false
177
+ imageUploader: comment.image_uploader === true ? false : undefined,
178
+ highlighter: comment.highlighter === true ? false : undefined,
179
+ texRenderer: comment.tex_renderer === true ? false : undefined,
180
+ search: comment.search === true ? false : undefined,
171
181
  pageview: comment.pageview,
172
182
  comment: comment.comment,
173
183
  copyright: comment.copyright,
@@ -75,7 +75,7 @@ Afdian.Cacheable = cacheComponent(Afdian, 'donate.afdian', function (props) {
75
75
  helper = props.helper;
76
76
  return {
77
77
  title: helper.__('donate.' + donate.type),
78
- url: helper.url_for(donate.url)
78
+ url: donate.url ? helper.url_for(donate.url) : null
79
79
  };
80
80
  });
81
81
  module.exports = Afdian;
@@ -75,7 +75,7 @@ Alipay.Cacheable = cacheComponent(Alipay, 'donate.alipay', function (props) {
75
75
  helper = props.helper;
76
76
  return {
77
77
  title: helper.__('donate.' + donate.type),
78
- qrcode: helper.url_for(donate.qrcode)
78
+ qrcode: donate.qrcode ? helper.url_for(donate.qrcode) : null
79
79
  };
80
80
  });
81
81
  module.exports = Alipay;
@@ -74,7 +74,7 @@ BuyMeACoffee.Cacheable = cacheComponent(BuyMeACoffee, 'donate.buymeacoffee', fun
74
74
  var donate = props.donate,
75
75
  helper = props.helper;
76
76
  return {
77
- url: helper.url_for(donate.url),
77
+ url: donate.url ? helper.url_for(donate.url) : null,
78
78
  title: helper.__('donate.' + donate.type)
79
79
  };
80
80
  });
@@ -74,7 +74,7 @@ Patreon.Cacheable = cacheComponent(Patreon, 'donate.petreon', function (props) {
74
74
  var donate = props.donate,
75
75
  helper = props.helper;
76
76
  return {
77
- url: helper.url_for(donate.url),
77
+ url: donate.url ? helper.url_for(donate.url) : null,
78
78
  title: helper.__('donate.' + donate.type)
79
79
  };
80
80
  });
@@ -74,7 +74,7 @@ Wechat.Cacheable = cacheComponent(Wechat, 'donate.wechat', function (props) {
74
74
  var donate = props.donate,
75
75
  helper = props.helper;
76
76
  return {
77
- qrcode: helper.url_for(donate.qrcode),
77
+ qrcode: donate.qrcode ? helper.url_for(donate.qrcode) : null,
78
78
  title: helper.__('donate.' + donate.type)
79
79
  };
80
80
  });
@@ -26,6 +26,11 @@ var _require = require('inferno'),
26
26
  function trim(str) {
27
27
  return str.trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1');
28
28
  }
29
+
30
+ // Remove the backslashes that escape ";" and "="
31
+ function unescape(str) {
32
+ return str.replace(/\\(.)/g, '$1');
33
+ }
29
34
  function split(str, sep) {
30
35
  var result = [];
31
36
  var matched = null;
@@ -63,11 +68,12 @@ module.exports = /*#__PURE__*/function (_Component) {
63
68
  return typeof entry === 'string';
64
69
  }).map(function (entry) {
65
70
  var props = split(entry, /(?:[^\\;]+|\\.)+/g).map(function (property) {
66
- var entry = split(property, /(?:[^\\=]+|\\.)+/g);
67
- if (entry.length < 2) {
71
+ // Split at the first "=" that is not escaped, so that the value can contain "="
72
+ var entry = /^((?:[^\\=]|\\[^])*)=([^]*)$/.exec(property);
73
+ if (!entry) {
68
74
  return null;
69
75
  }
70
- return _defineProperty({}, trim(entry[0]), trim(entry[1]));
76
+ return _defineProperty({}, unescape(trim(entry[1])), unescape(trim(entry[2])));
71
77
  }).filter(function (property) {
72
78
  return property !== null;
73
79
  }).reduce(function (prev, current) {