hexo-component-inferno 3.1.2 → 4.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.
Files changed (161) hide show
  1. package/asset/js/algolia.js +51 -10
  2. package/asset/js/google_cse.js +50 -7
  3. package/asset/js/insight.js +48 -7
  4. package/lib/hexo/filter/locals.js +2 -2
  5. package/lib/hexo/helper/cdn.js +10 -2
  6. package/lib/schema/comment/artalk.json +37 -0
  7. package/lib/schema/comment/beaudar.json +62 -0
  8. package/lib/schema/comment/cusdis.json +34 -0
  9. package/lib/schema/comment/giscus.json +7 -1
  10. package/lib/schema/comment/utterances.json +15 -1
  11. package/lib/schema/comment/valine.json +2 -2
  12. package/lib/schema/comment/waline.json +1 -1
  13. package/lib/schema/plugin/matomo.json +25 -0
  14. package/lib/schema/plugin/umami.json +25 -0
  15. package/lib/schema/plugin/waline_pageview.json +14 -0
  16. package/lib/schema/search/algolia.json +4 -0
  17. package/lib/schema/widget/archives.json +5 -0
  18. package/lib/schema/widget/categories.json +5 -0
  19. package/lib/schema/widget/tags.json +1 -1
  20. package/lib/util/appearance.js +40 -0
  21. package/lib/util/i18n.js +24 -0
  22. package/lib/util/script.js +110 -0
  23. package/lib/view/comment/artalk.js +118 -0
  24. package/lib/view/comment/beaudar.js +133 -0
  25. package/lib/view/comment/changyan.js +5 -5
  26. package/lib/view/comment/cusdis.js +119 -0
  27. package/lib/view/comment/disqus.js +1 -1
  28. package/lib/view/comment/disqusjs.js +6 -5
  29. package/lib/view/comment/facebook.js +1 -1
  30. package/lib/view/comment/giscus.js +32 -22
  31. package/lib/view/comment/gitalk.js +6 -5
  32. package/lib/view/comment/gitment.js +6 -5
  33. package/lib/view/comment/isso.js +7 -3
  34. package/lib/view/comment/livere.js +1 -1
  35. package/lib/view/comment/twikoo.js +3 -4
  36. package/lib/view/comment/utterances.js +26 -17
  37. package/lib/view/comment/valine.js +3 -6
  38. package/lib/view/comment/waline.js +16 -9
  39. package/lib/view/common/article_media.js +2 -2
  40. package/lib/view/donate/afdian.js +1 -1
  41. package/lib/view/donate/alipay.js +1 -1
  42. package/lib/view/donate/buymeacoffee.js +1 -1
  43. package/lib/view/donate/patreon.js +1 -1
  44. package/lib/view/donate/paypal.js +1 -1
  45. package/lib/view/donate/wechat.js +1 -1
  46. package/lib/view/misc/article_licensing.js +1 -1
  47. package/lib/view/misc/meta.js +1 -1
  48. package/lib/view/misc/open_graph.js +1 -1
  49. package/lib/view/misc/paginator.js +9 -5
  50. package/lib/view/misc/structured_data.js +1 -1
  51. package/lib/view/misc/web_app.js +2 -2
  52. package/lib/view/plugin/baidu_analytics.js +1 -1
  53. package/lib/view/plugin/bing_webmaster.js +1 -1
  54. package/lib/view/plugin/busuanzi.js +1 -1
  55. package/lib/view/plugin/cnzz.js +1 -1
  56. package/lib/view/plugin/cookie_consent.js +1 -1
  57. package/lib/view/plugin/gallery.js +2 -2
  58. package/lib/view/plugin/google_analytics.js +1 -1
  59. package/lib/view/plugin/hotjar.js +1 -1
  60. package/lib/view/plugin/katex.js +1 -1
  61. package/lib/view/plugin/mathjax.js +1 -1
  62. package/lib/view/plugin/matomo.js +89 -0
  63. package/lib/view/plugin/outdated_browser.js +1 -1
  64. package/lib/view/plugin/progressbar.js +1 -1
  65. package/lib/view/plugin/statcounter.js +1 -1
  66. package/lib/view/plugin/twitter_conversion_tracking.js +1 -1
  67. package/lib/view/plugin/umami.js +88 -0
  68. package/lib/view/plugin/waline_pageview.js +98 -0
  69. package/lib/view/search/algolia.js +11 -5
  70. package/lib/view/search/baidu.js +5 -3
  71. package/lib/view/search/google_cse.js +4 -2
  72. package/lib/view/search/insight.js +1 -1
  73. package/lib/view/share/addthis.js +1 -1
  74. package/lib/view/share/addtoany.js +1 -1
  75. package/lib/view/share/bdshare.js +1 -1
  76. package/lib/view/share/sharejs.js +1 -1
  77. package/lib/view/share/sharethis.js +1 -1
  78. package/lib/view/widget/adsense.js +1 -1
  79. package/lib/view/widget/archives.js +45 -12
  80. package/lib/view/widget/categories.js +23 -7
  81. package/lib/view/widget/followit.js +1 -1
  82. package/lib/view/widget/links.js +1 -1
  83. package/lib/view/widget/recent_posts.js +1 -1
  84. package/lib/view/widget/subscribe_email.js +1 -1
  85. package/lib/view/widget/tags.js +19 -6
  86. package/lib/view/widget/toc.js +1 -1
  87. package/package.json +10 -5
  88. package/lib/core/migrate.test.js +0 -48
  89. package/lib/core/schema.test.js +0 -520
  90. package/lib/core/view.test.js +0 -41
  91. package/lib/hexo/filter/locals.test.js +0 -118
  92. package/lib/hexo/generator/assets.test.js +0 -32
  93. package/lib/hexo/generator/categories.test.js +0 -41
  94. package/lib/hexo/generator/category.test.js +0 -84
  95. package/lib/hexo/generator/insight.test.js +0 -95
  96. package/lib/hexo/generator/manifest.test.js +0 -52
  97. package/lib/hexo/generator/tags.test.js +0 -41
  98. package/lib/hexo/helper/cdn.test.js +0 -128
  99. package/lib/hexo/helper/page.test.js +0 -62
  100. package/lib/hexo/tag/message.test.js +0 -72
  101. package/lib/hexo/tag/tabs.test.js +0 -98
  102. package/lib/schema/schema/comment/changyan.json +0 -21
  103. package/lib/schema/schema/comment/disqus.json +0 -17
  104. package/lib/schema/schema/comment/disqusjs.json +0 -53
  105. package/lib/schema/schema/comment/facebook.json +0 -13
  106. package/lib/schema/schema/comment/giscus.json +0 -105
  107. package/lib/schema/schema/comment/gitalk.json +0 -81
  108. package/lib/schema/schema/comment/gitment.json +0 -47
  109. package/lib/schema/schema/comment/isso.json +0 -17
  110. package/lib/schema/schema/comment/livere.json +0 -17
  111. package/lib/schema/schema/comment/twikoo.json +0 -28
  112. package/lib/schema/schema/comment/utterances.json +0 -59
  113. package/lib/schema/schema/comment/valine.json +0 -105
  114. package/lib/schema/schema/comment/waline.json +0 -176
  115. package/lib/schema/schema/donate/afdian.json +0 -17
  116. package/lib/schema/schema/donate/alipay.json +0 -17
  117. package/lib/schema/schema/donate/buymeacoffee.json +0 -17
  118. package/lib/schema/schema/donate/patreon.json +0 -17
  119. package/lib/schema/schema/donate/paypal.json +0 -22
  120. package/lib/schema/schema/donate/wechat.json +0 -17
  121. package/lib/schema/schema/misc/manifest.json +0 -66
  122. package/lib/schema/schema/misc/meta.json +0 -11
  123. package/lib/schema/schema/misc/open_graph.json +0 -78
  124. package/lib/schema/schema/misc/poly_links.json +0 -35
  125. package/lib/schema/schema/misc/structured_data.json +0 -47
  126. package/lib/schema/schema/plugin/baidu_analytics.json +0 -14
  127. package/lib/schema/schema/plugin/bing_webmaster.json +0 -14
  128. package/lib/schema/schema/plugin/busuanzi.json +0 -7
  129. package/lib/schema/schema/plugin/cnzz.json +0 -19
  130. package/lib/schema/schema/plugin/cookie_consent.json +0 -38
  131. package/lib/schema/schema/plugin/gallery.json +0 -7
  132. package/lib/schema/schema/plugin/google_analytics.json +0 -14
  133. package/lib/schema/schema/plugin/hotjar.json +0 -14
  134. package/lib/schema/schema/plugin/katex.json +0 -7
  135. package/lib/schema/schema/plugin/mathjax.json +0 -7
  136. package/lib/schema/schema/plugin/outdated_browser.json +0 -7
  137. package/lib/schema/schema/plugin/progressbar.json +0 -7
  138. package/lib/schema/schema/plugin/statcounter.json +0 -19
  139. package/lib/schema/schema/plugin/twitter_conversion_tracking.json +0 -14
  140. package/lib/schema/schema/search/algolia.json +0 -13
  141. package/lib/schema/schema/search/baidu.json +0 -13
  142. package/lib/schema/schema/search/google_cse.json +0 -17
  143. package/lib/schema/schema/search/insight.json +0 -19
  144. package/lib/schema/schema/share/addthis.json +0 -17
  145. package/lib/schema/schema/share/addtoany.json +0 -13
  146. package/lib/schema/schema/share/bdshare.json +0 -13
  147. package/lib/schema/schema/share/sharejs.json +0 -13
  148. package/lib/schema/schema/share/sharethis.json +0 -17
  149. package/lib/schema/schema/widget/adsense.json +0 -21
  150. package/lib/schema/schema/widget/archives.json +0 -13
  151. package/lib/schema/schema/widget/categories.json +0 -13
  152. package/lib/schema/schema/widget/followit.json +0 -26
  153. package/lib/schema/schema/widget/links.json +0 -47
  154. package/lib/schema/schema/widget/recent_posts.json +0 -13
  155. package/lib/schema/schema/widget/subscribe_email.json +0 -22
  156. package/lib/schema/schema/widget/tags.json +0 -30
  157. package/lib/schema/schema/widget/toc.json +0 -31
  158. package/lib/util/cache.test.js +0 -24
  159. package/lib/util/classname.test.js +0 -13
  160. package/lib/util/yaml.test.js +0 -18
  161. package/lib/view/widget/toc.test.js +0 -30
@@ -2,14 +2,11 @@
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; }
11
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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); }
13
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
14
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); }
15
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -25,6 +22,10 @@ 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
+ var _require4 = require('../../util/appearance'),
28
+ isDark = _require4.isDark;
28
29
 
29
30
  /**
30
31
  * Giscus comment JSX component.
@@ -42,6 +43,7 @@ var _require2 = require('../../util/cache'),
42
43
  * emitMetadata={0}
43
44
  * inputPosition="******"
44
45
  * theme="******"
46
+ * darkTheme="******"
45
47
  * lang="******"
46
48
  * lazy="******" />
47
49
  */
@@ -66,6 +68,7 @@ var Giscus = /*#__PURE__*/function (_Component) {
66
68
  emitMetadata = _this$props.emitMetadata,
67
69
  inputPosition = _this$props.inputPosition,
68
70
  theme = _this$props.theme,
71
+ darkTheme = _this$props.darkTheme,
69
72
  customThemeCss = _this$props.customThemeCss,
70
73
  lang = _this$props.lang,
71
74
  lazy = _this$props.lazy;
@@ -75,9 +78,7 @@ var Giscus = /*#__PURE__*/function (_Component) {
75
78
  if ((mapping === 'specific' || mapping === 'number') && !term) {
76
79
  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
80
  }
78
- var config = {
79
- repo: repo
80
- };
81
+ var config = {};
81
82
  config['data-repo'] = repo;
82
83
  config['data-repo-id'] = repoId;
83
84
  config['data-category-id'] = categoryId;
@@ -91,6 +92,9 @@ var Giscus = /*#__PURE__*/function (_Component) {
91
92
  } else {
92
93
  config['data-mapping'] = 'pathname';
93
94
  }
95
+ if (term) {
96
+ config['data-term'] = term;
97
+ }
94
98
  if (strict) {
95
99
  config['data-strict'] = 1;
96
100
  } else {
@@ -111,18 +115,16 @@ var Giscus = /*#__PURE__*/function (_Component) {
111
115
  } else {
112
116
  config['data-input-position'] = 'top';
113
117
  }
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
- }
118
+ // Use the dark theme when the page looks dark, unless the theme is custom
119
+ var dynamicConfig = {};
120
+ if (theme === 'custom') {
121
+ if (customThemeCss) {
122
+ config['data-theme'] = customThemeCss;
121
123
  } else {
122
- config['data-theme'] = theme;
124
+ 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
125
  }
124
126
  } else {
125
- config['data-theme'] = 'noborder_light';
127
+ dynamicConfig['data-theme'] = "".concat(isDark(), " ? ").concat(JSON.stringify(darkTheme || 'noborder_dark'), " : ").concat(JSON.stringify(theme || 'noborder_light'));
126
128
  }
127
129
  if (lang) {
128
130
  config['data-lang'] = lang;
@@ -132,12 +134,17 @@ var Giscus = /*#__PURE__*/function (_Component) {
132
134
  if (lazy) {
133
135
  config['data-loading'] = 'lazy';
134
136
  }
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
- })));
137
+ config.crossorigin = 'anonymous';
138
+ // Giscus puts its iframe into the element with the giscus class, so add its script to <head> to
139
+ // keep the number of scripts in the comment section the same for PJAX
140
+ var js = appendScript('head', 'https://giscus.app/client.js', config, dynamicConfig);
141
+ return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "giscus", null, 1, {
142
+ "id": "giscus-thread"
143
+ }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
144
+ "dangerouslySetInnerHTML": {
145
+ __html: js
146
+ }
147
+ })], 4);
141
148
  }
142
149
  }]);
143
150
  }(Component);
@@ -161,6 +168,7 @@ var Giscus = /*#__PURE__*/function (_Component) {
161
168
  * emitMetadata: {false}
162
169
  * inputPosition: "******"
163
170
  * theme: "******"
171
+ * darkTheme: "******"
164
172
  * lang: "******"
165
173
  * lazy: "******"
166
174
  * }} />
@@ -178,6 +186,7 @@ Giscus.Cacheable = cacheComponent(Giscus, 'comment.giscus', function (props) {
178
186
  emitMetadata = _props$comment.emitMetadata,
179
187
  inputPosition = _props$comment.inputPosition,
180
188
  theme = _props$comment.theme,
189
+ darkTheme = _props$comment.darkTheme,
181
190
  customThemeCss = _props$comment.customThemeCss,
182
191
  lang = _props$comment.lang,
183
192
  lazy = _props$comment.lazy;
@@ -193,6 +202,7 @@ Giscus.Cacheable = cacheComponent(Giscus, 'comment.giscus', function (props) {
193
202
  emitMetadata: emitMetadata,
194
203
  inputPosition: inputPosition,
195
204
  theme: theme,
205
+ darkTheme: darkTheme,
196
206
  customThemeCss: customThemeCss,
197
207
  lang: lang,
198
208
  lazy: lazy
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -23,6 +23,7 @@ var _require = require('inferno'),
23
23
  Component = _require.Component;
24
24
  var _require2 = require('../../util/cache'),
25
25
  cacheComponent = _require2.cacheComponent;
26
+ var loadScripts = require('../../util/script');
26
27
 
27
28
  /**
28
29
  * Gitalk comment JSX component.
@@ -85,12 +86,12 @@ var Gitalk = /*#__PURE__*/function (_Component) {
85
86
  "id": "comment-container"
86
87
  }), (0, _inferno.createVNode)(1, "link", null, null, 1, {
87
88
  "rel": "stylesheet",
88
- "href": cssUrl
89
- }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
90
- "src": jsUrl
89
+ "href": cssUrl,
90
+ "media": "print",
91
+ "onload": "this.media='all'"
91
92
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
92
93
  "dangerouslySetInnerHTML": {
93
- __html: js
94
+ __html: loadScripts(jsUrl, js)
94
95
  }
95
96
  })], 4);
96
97
  }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -24,6 +24,7 @@ var _require = require('inferno'),
24
24
  Component = _require.Component;
25
25
  var _require2 = require('../../util/cache'),
26
26
  cacheComponent = _require2.cacheComponent;
27
+ var loadScripts = require('../../util/script');
27
28
 
28
29
  /**
29
30
  * Gitment comment JSX component.
@@ -67,12 +68,12 @@ var Gitment = /*#__PURE__*/function (_Component) {
67
68
  "id": "comment-container"
68
69
  }), (0, _inferno.createVNode)(1, "link", null, null, 1, {
69
70
  "rel": "stylesheet",
70
- "href": "https://imsun.github.io/gitment/style/default.css"
71
- }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
72
- "src": "https://imsun.github.io/gitment/dist/gitment.browser.js"
71
+ "href": "https://imsun.github.io/gitment/style/default.css",
72
+ "media": "print",
73
+ "onload": "this.media='all'"
73
74
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
74
75
  "dangerouslySetInnerHTML": {
75
- __html: js
76
+ __html: loadScripts('https://imsun.github.io/gitment/dist/gitment.browser.js', js)
76
77
  }
77
78
  })], 4);
78
79
  }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -43,11 +43,15 @@ var Isso = /*#__PURE__*/function (_Component) {
43
43
  if (!url) {
44
44
  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
45
  }
46
+ // Isso renders the thread as soon as its script runs, so add a new script every time this code
47
+ // 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 })();");
46
49
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, null, 1, {
47
50
  "id": "isso-thread"
48
51
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
49
- "data-isso": '//' + url,
50
- "src": "//".concat(url, "/js/embed.min.js")
52
+ "dangerouslySetInnerHTML": {
53
+ __html: js
54
+ }
51
55
  })], 4);
52
56
  }
53
57
  }]);
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -23,6 +23,7 @@ var _require = require('inferno'),
23
23
  Fragment = _require.Fragment;
24
24
  var _require2 = require('../../util/cache'),
25
25
  cacheComponent = _require2.cacheComponent;
26
+ var loadScripts = require('../../util/script');
26
27
 
27
28
  /**
28
29
  * Twikoo comment JSX component.
@@ -52,11 +53,9 @@ var Twikoo = /*#__PURE__*/function (_Component) {
52
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 });");
53
54
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "content twikoo", null, 1, {
54
55
  "id": "twikoo"
55
- }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
56
- "src": jsUrl
57
56
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
58
57
  "dangerouslySetInnerHTML": {
59
- __html: js
58
+ __html: loadScripts(jsUrl, js)
60
59
  }
61
60
  })], 4);
62
61
  }
@@ -2,14 +2,11 @@
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; }
11
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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); }
13
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
14
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); }
15
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -25,6 +22,10 @@ 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
+ var _require4 = require('../../util/appearance'),
28
+ isDark = _require4.isDark;
28
29
 
29
30
  /**
30
31
  * Utterances comment JSX component.
@@ -36,7 +37,8 @@ var _require2 = require('../../util/cache'),
36
37
  * issueTerm="******"
37
38
  * issueNumber={123}
38
39
  * label="******"
39
- * theme="******" />
40
+ * theme="******"
41
+ * darkTheme="******" />
40
42
  */
41
43
  var Utterances = /*#__PURE__*/function (_Component) {
42
44
  function Utterances() {
@@ -52,7 +54,8 @@ var Utterances = /*#__PURE__*/function (_Component) {
52
54
  issueTerm = _this$props.issueTerm,
53
55
  issueNumber = _this$props.issueNumber,
54
56
  label = _this$props.label,
55
- theme = _this$props.theme;
57
+ theme = _this$props.theme,
58
+ darkTheme = _this$props.darkTheme;
56
59
  if (!repo || !issueTerm && !issueNumber) {
57
60
  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
61
  }
@@ -67,15 +70,18 @@ var Utterances = /*#__PURE__*/function (_Component) {
67
70
  if (label) {
68
71
  config.label = label;
69
72
  }
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
- })));
73
+ config.crossorigin = 'anonymous';
74
+ // Use the dark theme when the page looks dark
75
+ var js = appendScript('#utterances-thread', 'https://utteranc.es/client.js', config, {
76
+ theme: "".concat(isDark(), " ? ").concat(JSON.stringify(darkTheme || 'github-dark'), " : ").concat(JSON.stringify(theme || 'github-light'))
77
+ });
78
+ return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, null, 1, {
79
+ "id": "utterances-thread"
80
+ }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
81
+ "dangerouslySetInnerHTML": {
82
+ __html: js
83
+ }
84
+ })], 4);
79
85
  }
80
86
  }]);
81
87
  }(Component);
@@ -94,6 +100,7 @@ var Utterances = /*#__PURE__*/function (_Component) {
94
100
  * issue_number: {123}
95
101
  * label: "******"
96
102
  * theme: "******"
103
+ * dark_theme: "******"
97
104
  * }} />
98
105
  */
99
106
  Utterances.Cacheable = cacheComponent(Utterances, 'comment.utterances', function (props) {
@@ -102,13 +109,15 @@ Utterances.Cacheable = cacheComponent(Utterances, 'comment.utterances', function
102
109
  issue_term = _props$comment.issue_term,
103
110
  issue_number = _props$comment.issue_number,
104
111
  label = _props$comment.label,
105
- theme = _props$comment.theme;
112
+ theme = _props$comment.theme,
113
+ dark_theme = _props$comment.dark_theme;
106
114
  return {
107
115
  repo: repo,
108
116
  issueTerm: issue_term,
109
117
  issueNumber: issue_number,
110
118
  label: label,
111
- theme: theme
119
+ theme: theme,
120
+ darkTheme: dark_theme
112
121
  };
113
122
  });
114
123
  module.exports = Utterances;
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -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
  * Valine comment JSX component.
@@ -93,13 +94,9 @@ var Valine = /*#__PURE__*/function (_Component) {
93
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 });");
94
95
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "content", null, 1, {
95
96
  "id": "valine-thread"
96
- }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
97
- "src": "//cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js"
98
- }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
99
- "src": jsUrl
100
97
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
101
98
  "dangerouslySetInnerHTML": {
102
- __html: js
99
+ __html: loadScripts(['//cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js', jsUrl], js)
103
100
  }
104
101
  })], 4);
105
102
  }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -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/appearance'),
26
+ getAppearance = _require3.getAppearance;
25
27
 
26
28
  /**
27
29
  * Waline comment JSX component.
@@ -68,8 +70,7 @@ var Waline = /*#__PURE__*/function (_Component) {
68
70
  locale = _this$props.locale,
69
71
  _this$props$emoji = _this$props.emoji,
70
72
  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,
73
+ dark = _this$props.dark,
73
74
  _this$props$meta = _this$props.meta,
74
75
  meta = _this$props$meta === void 0 ? ['nick', 'mail', 'link'] : _this$props$meta,
75
76
  _this$props$requiredM = _this$props.requiredMeta,
@@ -99,14 +100,20 @@ var Waline = /*#__PURE__*/function (_Component) {
99
100
  if (!serverURL) {
100
101
  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
102
  }
102
- var js = "Waline.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 });");
103
+ // Without the dark option, follow the appearance of the page: the system color scheme for the auto
104
+ // appearance, or the data-appearance="dark" attribute of <html> otherwise
105
+ var darkOption = dark === null || typeof dark === 'undefined' || dark === '' ? "".concat(getAppearance(), " === 'auto' ? 'auto' : 'html[data-appearance=\"dark\"]'") : JSON.stringify(dark);
106
+ // Use a classic script with a dynamic import instead of a module script, so that PJAX, which only
107
+ // runs classic scripts, initializes Waline again after switching pages. The previous instance,
108
+ // whose element PJAX has replaced, is destroyed first.
109
+ var js = "import(".concat(JSON.stringify(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(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 dark: ").concat(darkOption, ",\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 });\n });");
103
110
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "content", null, 1, {
104
111
  "id": "waline-thread"
105
112
  }), (0, _inferno.createVNode)(1, "link", null, null, 1, {
106
113
  "rel": "stylesheet",
107
- "href": cssUrl
108
- }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
109
- "src": jsUrl
114
+ "href": cssUrl,
115
+ "media": "print",
116
+ "onload": "this.media='all'"
110
117
  }), (0, _inferno.createVNode)(1, "script", null, null, 1, {
111
118
  "dangerouslySetInnerHTML": {
112
119
  __html: js
@@ -170,8 +177,8 @@ Waline.Cacheable = cacheComponent(Waline, 'comment.waline', function (props) {
170
177
  pageview: comment.pageview,
171
178
  comment: comment.comment,
172
179
  copyright: comment.copyright,
173
- jsUrl: helper.cdn('@waline/client', '2.6.3', 'dist/waline.js'),
174
- cssUrl: helper.cdn('@waline/client', '2.6.3', 'dist/waline.css')
180
+ jsUrl: helper.cdn('@waline/client', '3.3.0', 'dist/waline.js'),
181
+ cssUrl: helper.cdn('@waline/client', '3.3.0', 'dist/waline.css')
175
182
  };
176
183
  });
177
184
  module.exports = Waline;
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -67,7 +67,7 @@ module.exports = /*#__PURE__*/function (_Component) {
67
67
  }), 2, {
68
68
  "href": url
69
69
  }), 2) : null, (0, _inferno.createVNode)(1, "div", "media-content", [(0, _inferno.createVNode)(1, "p", "date", (0, _inferno.createVNode)(1, "time", null, date, 0, {
70
- "dateTime": dateXml
70
+ "datetime": dateXml
71
71
  }), 2), (0, _inferno.createVNode)(1, "p", "title", (0, _inferno.createVNode)(1, "a", null, title, 0, {
72
72
  "href": url
73
73
  }), 2), categoryTags.length ? (0, _inferno.createVNode)(1, "p", "categories", categoryTags, 0) : null], 0)], 0);
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
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
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
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
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
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }