hexo-component-inferno 4.1.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 (72) 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 +1 -1
  13. package/lib/hexo/tag/message.js +11 -1
  14. package/lib/hexo/tag/tabs.js +28 -5
  15. package/lib/schema/comment/giscus.json +5 -0
  16. package/lib/schema/comment/gitment.json +1 -1
  17. package/lib/schema/comment/valine.json +1 -1
  18. package/lib/schema/comment/waline.json +1 -1
  19. package/lib/schema/misc/open_graph.json +0 -1
  20. package/lib/schema/plugin/waline_pageview.json +1 -1
  21. package/lib/schema/share/addthis.json +1 -1
  22. package/lib/schema/widget/archives.json +23 -0
  23. package/lib/schema/widget/categories.json +27 -0
  24. package/lib/schema/widget/recent_posts.json +5 -0
  25. package/lib/schema/widget/subscribe_email.json +1 -1
  26. package/lib/util/classname.js +1 -1
  27. package/lib/util/deprecate.js +28 -0
  28. package/lib/util/html.js +51 -0
  29. package/lib/util/script.js +30 -7
  30. package/lib/view/comment/artalk.js +3 -2
  31. package/lib/view/comment/beaudar.js +3 -2
  32. package/lib/view/comment/changyan.js +2 -1
  33. package/lib/view/comment/cusdis.js +2 -1
  34. package/lib/view/comment/disqus.js +3 -1
  35. package/lib/view/comment/disqusjs.js +3 -2
  36. package/lib/view/comment/facebook.js +3 -1
  37. package/lib/view/comment/giscus.js +3 -2
  38. package/lib/view/comment/gitalk.js +4 -2
  39. package/lib/view/comment/gitment.js +7 -2
  40. package/lib/view/comment/isso.js +5 -1
  41. package/lib/view/comment/twikoo.js +5 -1
  42. package/lib/view/comment/utterances.js +3 -2
  43. package/lib/view/comment/valine.js +7 -1
  44. package/lib/view/comment/waline.js +25 -21
  45. package/lib/view/donate/afdian.js +1 -1
  46. package/lib/view/donate/alipay.js +1 -1
  47. package/lib/view/donate/buymeacoffee.js +1 -1
  48. package/lib/view/donate/patreon.js +1 -1
  49. package/lib/view/donate/wechat.js +1 -1
  50. package/lib/view/misc/meta.js +9 -3
  51. package/lib/view/misc/open_graph.js +12 -15
  52. package/lib/view/misc/structured_data.js +8 -9
  53. package/lib/view/misc/web_app.js +15 -6
  54. package/lib/view/plugin/baidu_analytics.js +3 -1
  55. package/lib/view/plugin/cookie_consent.js +3 -1
  56. package/lib/view/plugin/google_analytics.js +3 -1
  57. package/lib/view/plugin/hotjar.js +3 -1
  58. package/lib/view/plugin/matomo.js +3 -1
  59. package/lib/view/plugin/outdated_browser.js +1 -1
  60. package/lib/view/plugin/statcounter.js +3 -1
  61. package/lib/view/plugin/twitter_conversion_tracking.js +3 -1
  62. package/lib/view/plugin/waline_pageview.js +3 -1
  63. package/lib/view/search/algolia.js +3 -1
  64. package/lib/view/search/baidu.js +3 -1
  65. package/lib/view/search/google_cse.js +3 -1
  66. package/lib/view/search/insight.js +4 -2
  67. package/lib/view/share/addthis.js +4 -0
  68. package/lib/view/widget/archives.js +15 -2
  69. package/lib/view/widget/categories.js +20 -10
  70. package/lib/view/widget/links.js +1 -1
  71. package/lib/view/widget/subscribe_email.js +5 -0
  72. package/package.json +4 -2
@@ -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, {
@@ -23,7 +23,8 @@ var _require = require('inferno'),
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
25
  var _require3 = require('../../util/script'),
26
- appendScript = _require3.appendScript;
26
+ appendScript = _require3.appendScript,
27
+ toJs = _require3.toJs;
27
28
  var _require4 = require('../../util/appearance'),
28
29
  isDark = _require4.isDark;
29
30
 
@@ -73,7 +74,7 @@ var Utterances = /*#__PURE__*/function (_Component) {
73
74
  config.crossorigin = 'anonymous';
74
75
  // Use the dark theme when the page looks dark
75
76
  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
+ theme: "".concat(isDark(), " ? ").concat(toJs(darkTheme || 'github-dark'), " : ").concat(toJs(theme || 'github-light'))
77
78
  });
78
79
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", null, null, 1, {
79
80
  "id": "utterances-thread"
@@ -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,8 +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/appearance'),
26
- getAppearance = _require3.getAppearance;
25
+ var _require3 = require('../../util/script'),
26
+ toJs = _require3.toJs;
27
+ var _require4 = require('../../util/appearance'),
28
+ getAppearance = _require4.getAppearance;
27
29
 
28
30
  /**
29
31
  * Waline comment JSX component.
@@ -63,8 +65,7 @@ var Waline = /*#__PURE__*/function (_Component) {
63
65
  value: function render() {
64
66
  var _this$props = this.props,
65
67
  serverURL = _this$props.serverURL,
66
- _this$props$path = _this$props.path,
67
- path = _this$props$path === void 0 ? 'window.location.pathname' : _this$props$path,
68
+ path = _this$props.path,
68
69
  _this$props$lang = _this$props.lang,
69
70
  lang = _this$props$lang === void 0 ? 'zh-CN' : _this$props$lang,
70
71
  locale = _this$props.locale,
@@ -81,14 +82,10 @@ var Waline = /*#__PURE__*/function (_Component) {
81
82
  wordLimit = _this$props$wordLimit === void 0 ? 0 : _this$props$wordLimit,
82
83
  _this$props$pageSize = _this$props.pageSize,
83
84
  pageSize = _this$props$pageSize === void 0 ? 10 : _this$props$pageSize,
84
- _this$props$imageUplo = _this$props.imageUploader,
85
- imageUploader = _this$props$imageUplo === void 0 ? false : _this$props$imageUplo,
86
- _this$props$highlight = _this$props.highlighter,
87
- highlighter = _this$props$highlight === void 0 ? false : _this$props$highlight,
88
- _this$props$texRender = _this$props.texRenderer,
89
- texRenderer = _this$props$texRender === void 0 ? false : _this$props$texRender,
90
- _this$props$search = _this$props.search,
91
- 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,
92
89
  _this$props$pageview = _this$props.pageview,
93
90
  pageview = _this$props$pageview === void 0 ? false : _this$props$pageview,
94
91
  _this$props$comment = _this$props.comment,
@@ -102,11 +99,16 @@ var Waline = /*#__PURE__*/function (_Component) {
102
99
  }
103
100
  // Without the dark option, follow the appearance of the page: the system color scheme for the auto
104
101
  // 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);
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
+ }
106
108
  // Use a classic script with a dynamic import instead of a module script, so that PJAX, which only
107
109
  // runs classic scripts, initializes Waline again after switching pages. The previous instance,
108
110
  // 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 });");
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 });");
110
112
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "content", null, 1, {
111
113
  "id": "waline-thread"
112
114
  }), (0, _inferno.createVNode)(1, "link", null, null, 1, {
@@ -143,10 +145,10 @@ var Waline = /*#__PURE__*/function (_Component) {
143
145
  * login: false,
144
146
  * word_limit: 0,
145
147
  * page_size: 10,
146
- * image_uploader: true,
147
- * highlighter: true,
148
+ * image_uploader: false,
149
+ * highlighter: false,
148
150
  * tex_renderer: false,
149
- * search: true,
151
+ * search: false,
150
152
  * pageview: false,
151
153
  * comment: false,
152
154
  * copyright: true,
@@ -170,10 +172,12 @@ Waline.Cacheable = cacheComponent(Waline, 'comment.waline', function (props) {
170
172
  login: comment.login,
171
173
  wordLimit: comment.word_limit,
172
174
  pageSize: comment.page_size,
173
- imageUploader: comment.image_uploader,
174
- highlighter: comment.highlighter,
175
- texRenderer: comment.tex_renderer,
176
- 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,
177
181
  pageview: comment.pageview,
178
182
  comment: comment.comment,
179
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) {
@@ -26,9 +26,9 @@ var moment = require('moment');
26
26
  var _require = require('inferno'),
27
27
  Component = _require.Component;
28
28
  var _require2 = require('hexo-util'),
29
- encodeURL = _require2.encodeURL,
30
- stripHTML = _require2.stripHTML,
31
- escapeHTML = _require2.escapeHTML;
29
+ encodeURL = _require2.encodeURL;
30
+ var _require3 = require('../../util/html'),
31
+ toPlainText = _require3.toPlainText;
32
32
  var localeMap = {
33
33
  en: 'en_US',
34
34
  de: 'de_DE',
@@ -45,7 +45,6 @@ var localeMap = {
45
45
  tr: 'tr_TR',
46
46
  vi: 'vi_VN'
47
47
  };
48
- var localeRegex = new RegExp(Object.keys(localeMap).join('|'), 'i');
49
48
 
50
49
  /**
51
50
  * A JSX component that renders Open Graph tags.
@@ -103,7 +102,8 @@ module.exports = /*#__PURE__*/function (_Component) {
103
102
  twitterId = _this$props2.twitterId;
104
103
  var htmlTags = [];
105
104
  if (description) {
106
- description = escapeHTML(stripHTML(description).substring(0, 200).trim()).replace(/\n/g, ' ');
105
+ // Plain text, which Inferno escapes in the attribute
106
+ description = toPlainText(description).substring(0, 200).trim();
107
107
  htmlTags.push((0, _inferno.createVNode)(1, "meta", null, null, 1, {
108
108
  "name": "description",
109
109
  "content": description
@@ -133,13 +133,12 @@ module.exports = /*#__PURE__*/function (_Component) {
133
133
  }
134
134
  if (language) {
135
135
  if (language.length === 2) {
136
- language = language.replace(localeRegex, function (str) {
137
- return localeMap[str];
138
- });
139
- htmlTags.push((0, _inferno.createVNode)(1, "meta", null, null, 1, {
140
- "property": "og:locale",
141
- "content": language
142
- }));
136
+ if (localeMap[language.toLowerCase()]) {
137
+ htmlTags.push((0, _inferno.createVNode)(1, "meta", null, null, 1, {
138
+ "property": "og:locale",
139
+ "content": localeMap[language.toLowerCase()]
140
+ }));
141
+ }
143
142
  } else if (language.length === 5) {
144
143
  var territory = language.slice(-2);
145
144
  var territoryRegex = new RegExp(territory.concat('$'));
@@ -150,9 +149,7 @@ module.exports = /*#__PURE__*/function (_Component) {
150
149
  }));
151
150
  }
152
151
  }
153
- if (!Array.isArray(images)) {
154
- images = [images];
155
- }
152
+ images = [].concat(images || []).filter(Boolean);
156
153
  images.map(function (path) {
157
154
  if (!urlFn.parse(path).host) {
158
155
  // resolve `path`'s absolute path relative to current page's url
@@ -22,9 +22,10 @@ var urlFn = require('url');
22
22
  var moment = require('moment');
23
23
  var _require = require('inferno'),
24
24
  Component = _require.Component;
25
- var _require2 = require('hexo-util'),
26
- stripHTML = _require2.stripHTML,
27
- escapeHTML = _require2.escapeHTML;
25
+ var _require2 = require('../../util/script'),
26
+ toJs = _require2.toJs;
27
+ var _require3 = require('../../util/html'),
28
+ toPlainText = _require3.toPlainText;
28
29
 
29
30
  /**
30
31
  * A JSX component that renders simple Google structured data.
@@ -63,11 +64,9 @@ module.exports = /*#__PURE__*/function (_Component) {
63
64
  updated = _this$props2.updated,
64
65
  publisherLogo = _this$props2.publisherLogo;
65
66
  if (description) {
66
- description = escapeHTML(stripHTML(description).substring(0, 200).trim()).replace(/\n/g, ' ');
67
- }
68
- if (!Array.isArray(images)) {
69
- images = [images];
67
+ description = toPlainText(description).substring(0, 200).trim();
70
68
  }
69
+ images = [].concat(images || []).filter(Boolean);
71
70
  images = images.map(function (path) {
72
71
  if (!urlFn.parse(path).host) {
73
72
  // resolve `path`'s absolute path relative to current page's url
@@ -76,7 +75,7 @@ module.exports = /*#__PURE__*/function (_Component) {
76
75
  }
77
76
  return path;
78
77
  }).filter(function (url) {
79
- return url.endsWith('.jpg') || url.endsWith('.png') || url.endsWith('.gif') || url.endsWith('.webp');
78
+ return /\.(jpe?g|png|gif|webp|avif|svg)$/i.test(urlFn.parse(url).pathname || '');
80
79
  });
81
80
  if (typeof publisherLogo === 'string' && !urlFn.parse(publisherLogo).host) {
82
81
  publisherLogo = urlFn.resolve(url, publisherLogo);
@@ -115,7 +114,7 @@ module.exports = /*#__PURE__*/function (_Component) {
115
114
  return (0, _inferno.createVNode)(1, "script", null, null, 1, {
116
115
  "type": "application/ld+json",
117
116
  "dangerouslySetInnerHTML": {
118
- __html: JSON.stringify(data)
117
+ __html: toJs(data)
119
118
  }
120
119
  });
121
120
  }
@@ -2,6 +2,9 @@
2
2
 
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
4
  var _inferno = require("inferno");
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
8
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
6
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
10
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -132,28 +135,34 @@ WebApp.Cacheable = cacheComponent(WebApp, 'misc.webapp', function (props) {
132
135
  var name = props.name,
133
136
  themeColor = props.themeColor,
134
137
  favicon = props.favicon,
135
- icons = props.icons,
136
138
  helper = props.helper;
139
+ var url_for = helper.url_for;
140
+ // Resolve the icons against the root of the site, like the manifest
141
+ var icons = Array.isArray(props.icons) ? props.icons.map(function (icon) {
142
+ return icon && icon.src ? _objectSpread(_objectSpread({}, icon), {}, {
143
+ src: url_for(icon.src)
144
+ }) : icon;
145
+ }) : props.icons;
137
146
  var tileIcon = null;
138
147
  if (Array.isArray(icons)) {
139
148
  tileIcon = icons.find(function (icon) {
140
- return icon.sizes.toLowerCase().indexOf('144x144') > -1;
149
+ return icon && typeof icon.sizes === 'string' && icon.sizes.toLowerCase().indexOf('144x144') > -1;
141
150
  });
142
151
  if (tileIcon) {
143
152
  tileIcon = tileIcon.src;
144
153
  } else if (icons.length) {
145
- tileIcon = icons[0].src;
154
+ tileIcon = (icons[0] || {}).src;
146
155
  }
147
156
  }
148
- if (!tileIcon) {
149
- tileIcon = favicon;
157
+ if (!tileIcon && favicon) {
158
+ tileIcon = url_for(favicon);
150
159
  }
151
160
  return {
152
161
  name: name,
153
162
  icons: icons,
154
163
  tileIcon: tileIcon,
155
164
  themeColor: themeColor,
156
- manifest: helper.url_for('/manifest.json')
165
+ manifest: url_for('/manifest.json')
157
166
  };
158
167
  });
159
168
  module.exports = WebApp;
@@ -22,6 +22,8 @@ var _require = require('inferno'),
22
22
  Component = _require.Component;
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Baidu Analytics plugin JSX component.
@@ -40,7 +42,7 @@ var BaiduAnalytics = /*#__PURE__*/function (_Component) {
40
42
  key: "render",
41
43
  value: function render() {
42
44
  var trackingId = this.props.trackingId;
43
- var js = "var _hmt = _hmt || [];\n (function() {\n var hm = document.createElement(\"script\");\n hm.src = \"//hm.baidu.com/hm.js?".concat(trackingId, "\";\n var s = document.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(hm, s);\n })();");
45
+ var js = "var _hmt = _hmt || [];\n (function() {\n var hm = document.createElement(\"script\");\n hm.src = ".concat(toJs("//hm.baidu.com/hm.js?".concat(trackingId)), ";\n var s = document.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(hm, s);\n })();");
44
46
  return (0, _inferno.createVNode)(1, "script", null, null, 1, {
45
47
  "dangerouslySetInnerHTML": {
46
48
  __html: js
@@ -22,6 +22,8 @@ var _require = require('inferno'),
22
22
  Component = _require.Component;
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * A JSX component for alerting users about the use of cookies.
@@ -71,7 +73,7 @@ var CookieConsent = /*#__PURE__*/function (_Component) {
71
73
  deny = text.deny,
72
74
  link = text.link,
73
75
  policy = text.policy;
74
- var js = "window.addEventListener(\"load\", () => {\n window.cookieconsent.initialise({\n type: ".concat(JSON.stringify(type), ",\n theme: ").concat(JSON.stringify(theme), ",\n static: ").concat(JSON.stringify(this.props["static"]), ",\n position: ").concat(JSON.stringify(position), ",\n content: {\n message: ").concat(JSON.stringify(message), ",\n dismiss: ").concat(JSON.stringify(dismiss), ",\n allow: ").concat(JSON.stringify(allow), ",\n deny: ").concat(JSON.stringify(deny), ",\n link: ").concat(JSON.stringify(link), ",\n policy: ").concat(JSON.stringify(policy), ",\n href: ").concat(JSON.stringify(policyLink), ",\n },\n palette: {\n popup: {\n background: \"#edeff5\",\n text: \"#838391\"\n },\n button: {\n background: \"#4b81e8\"\n },\n },\n });\n });");
76
+ var js = "window.addEventListener(\"load\", () => {\n window.cookieconsent.initialise({\n type: ".concat(toJs(type), ",\n theme: ").concat(toJs(theme), ",\n static: ").concat(toJs(this.props["static"]), ",\n position: ").concat(toJs(position), ",\n content: {\n message: ").concat(toJs(message), ",\n dismiss: ").concat(toJs(dismiss), ",\n allow: ").concat(toJs(allow), ",\n deny: ").concat(toJs(deny), ",\n link: ").concat(toJs(link), ",\n policy: ").concat(toJs(policy), ",\n href: ").concat(toJs(policyLink), ",\n },\n palette: {\n popup: {\n background: \"#edeff5\",\n text: \"#838391\"\n },\n button: {\n background: \"#4b81e8\"\n },\n },\n });\n });");
75
77
  if (head) {
76
78
  return (0, _inferno.createVNode)(1, "link", null, null, 1, {
77
79
  "rel": "stylesheet",
@@ -22,6 +22,8 @@ var _require = require('inferno'),
22
22
  Component = _require.Component;
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Google Analytics plugin JSX component.
@@ -40,7 +42,7 @@ var GoogleAnalytics = /*#__PURE__*/function (_Component) {
40
42
  key: "render",
41
43
  value: function render() {
42
44
  var trackingId = this.props.trackingId;
43
- var js = "window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n \n gtag('config', '".concat(trackingId, "');");
45
+ var js = "window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n \n gtag('config', ".concat(toJs(trackingId), ");");
44
46
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "script", null, null, 1, {
45
47
  "src": "https://www.googletagmanager.com/gtag/js?id=".concat(trackingId),
46
48
  "async": true
@@ -22,6 +22,8 @@ var _require = require('inferno'),
22
22
  Component = _require.Component;
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Hotjar user feedback plugin JSX component.
@@ -40,7 +42,7 @@ var Hotjar = /*#__PURE__*/function (_Component) {
40
42
  key: "render",
41
43
  value: function render() {
42
44
  var siteId = this.props.siteId;
43
- var js = "(function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:".concat(siteId, ",hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');");
45
+ var js = "(function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:".concat(toJs(siteId), ",hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');");
44
46
  return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "script", null, null, 1, {
45
47
  "dangerouslySetInnerHTML": {
46
48
  __html: js
@@ -22,6 +22,8 @@ var _require = require('inferno'),
22
22
  Component = _require.Component;
23
23
  var _require2 = require('../../util/cache'),
24
24
  cacheComponent = _require2.cacheComponent;
25
+ var _require3 = require('../../util/script'),
26
+ toJs = _require3.toJs;
25
27
 
26
28
  /**
27
29
  * Matomo analytics plugin JSX component.
@@ -49,7 +51,7 @@ var Matomo = /*#__PURE__*/function (_Component) {
49
51
  siteId = _this$props.siteId,
50
52
  disableCookies = _this$props.disableCookies;
51
53
  var baseUrl = url.endsWith('/') ? url : url + '/';
52
- var js = "var _paq = window._paq = window._paq || [];\n ".concat(disableCookies ? "_paq.push(['disableCookies']);" : '', "\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n (function () {\n var u = ").concat(JSON.stringify(baseUrl), ";\n _paq.push(['setTrackerUrl', u + 'matomo.php']);\n _paq.push(['setSiteId', ").concat(JSON.stringify(String(siteId)), "]);\n var g = document.createElement('script');\n g.async = true;\n g.src = u + 'matomo.js';\n document.head.appendChild(g);\n })();\n (function () {\n var referrer = location.href;\n document.addEventListener('pjax:complete', function () {\n _paq.push(['setReferrerUrl', referrer]);\n referrer = location.href;\n _paq.push(['setCustomUrl', referrer]);\n _paq.push(['setDocumentTitle', document.title]);\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n });\n })();");
54
+ var js = "var _paq = window._paq = window._paq || [];\n ".concat(disableCookies ? "_paq.push(['disableCookies']);" : '', "\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n (function () {\n var u = ").concat(toJs(baseUrl), ";\n _paq.push(['setTrackerUrl', u + 'matomo.php']);\n _paq.push(['setSiteId', ").concat(toJs(String(siteId)), "]);\n var g = document.createElement('script');\n g.async = true;\n g.src = u + 'matomo.js';\n document.head.appendChild(g);\n })();\n (function () {\n var referrer = location.href;\n document.addEventListener('pjax:complete', function () {\n _paq.push(['setReferrerUrl', referrer]);\n referrer = location.href;\n _paq.push(['setCustomUrl', referrer]);\n _paq.push(['setDocumentTitle', document.title]);\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n });\n })();");
53
55
  return (0, _inferno.createVNode)(1, "script", null, null, 1, {
54
56
  "dangerouslySetInnerHTML": {
55
57
  __html: js