hexo-component-inferno 1.0.2 → 2.0.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 (125) hide show
  1. package/lib/hexo/generator/insight.js +8 -1
  2. package/lib/hexo/generator/insight.test.js +16 -0
  3. package/lib/hexo/helper/cdn.js +4 -11
  4. package/lib/hexo/helper/cdn.test.js +9 -37
  5. package/lib/hexo/tag/message.js +100 -0
  6. package/lib/hexo/tag/message.test.js +79 -0
  7. package/lib/hexo/tag/tabs.js +290 -0
  8. package/lib/hexo/tag/tabs.test.js +106 -0
  9. package/lib/schema/comment/twikoo.json +28 -0
  10. package/lib/schema/comment/waline.json +46 -43
  11. package/lib/schema/schema/comment/changyan.json +21 -0
  12. package/lib/schema/schema/comment/disqus.json +17 -0
  13. package/lib/schema/schema/comment/disqusjs.json +53 -0
  14. package/lib/schema/schema/comment/facebook.json +13 -0
  15. package/lib/schema/schema/comment/gitalk.json +81 -0
  16. package/lib/schema/schema/comment/gitment.json +47 -0
  17. package/lib/schema/schema/comment/isso.json +17 -0
  18. package/lib/schema/schema/comment/livere.json +17 -0
  19. package/lib/schema/schema/comment/twikoo.json +28 -0
  20. package/lib/schema/schema/comment/utterances.json +59 -0
  21. package/lib/schema/schema/comment/valine.json +105 -0
  22. package/lib/schema/schema/comment/waline.json +176 -0
  23. package/lib/schema/schema/donate/afdian.json +17 -0
  24. package/lib/schema/schema/donate/alipay.json +17 -0
  25. package/lib/schema/schema/donate/buymeacoffee.json +17 -0
  26. package/lib/schema/schema/donate/patreon.json +17 -0
  27. package/lib/schema/schema/donate/paypal.json +22 -0
  28. package/lib/schema/schema/donate/wechat.json +17 -0
  29. package/lib/schema/schema/misc/manifest.json +66 -0
  30. package/lib/schema/schema/misc/meta.json +11 -0
  31. package/lib/schema/schema/misc/open_graph.json +78 -0
  32. package/lib/schema/schema/misc/poly_links.json +35 -0
  33. package/lib/schema/schema/misc/structured_data.json +47 -0
  34. package/lib/schema/schema/plugin/baidu_analytics.json +14 -0
  35. package/lib/schema/schema/plugin/bing_webmaster.json +14 -0
  36. package/lib/schema/schema/plugin/busuanzi.json +7 -0
  37. package/lib/schema/schema/plugin/cnzz.json +19 -0
  38. package/lib/schema/schema/plugin/cookie_consent.json +38 -0
  39. package/lib/schema/schema/plugin/gallery.json +7 -0
  40. package/lib/schema/schema/plugin/google_analytics.json +14 -0
  41. package/lib/schema/schema/plugin/hotjar.json +14 -0
  42. package/lib/schema/schema/plugin/katex.json +7 -0
  43. package/lib/schema/schema/plugin/mathjax.json +7 -0
  44. package/lib/schema/schema/plugin/outdated_browser.json +7 -0
  45. package/lib/schema/schema/plugin/progressbar.json +7 -0
  46. package/lib/schema/schema/plugin/statcounter.json +19 -0
  47. package/lib/schema/schema/plugin/twitter_conversion_tracking.json +14 -0
  48. package/lib/schema/schema/search/algolia.json +13 -0
  49. package/lib/schema/schema/search/baidu.json +13 -0
  50. package/lib/schema/schema/search/google_cse.json +17 -0
  51. package/lib/schema/schema/search/insight.json +19 -0
  52. package/lib/schema/schema/share/addthis.json +17 -0
  53. package/lib/schema/schema/share/addtoany.json +13 -0
  54. package/lib/schema/schema/share/bdshare.json +13 -0
  55. package/lib/schema/schema/share/sharejs.json +13 -0
  56. package/lib/schema/schema/share/sharethis.json +17 -0
  57. package/lib/schema/schema/widget/adsense.json +21 -0
  58. package/lib/schema/schema/widget/archives.json +13 -0
  59. package/lib/schema/schema/widget/categories.json +13 -0
  60. package/lib/schema/schema/widget/followit.json +26 -0
  61. package/lib/schema/schema/widget/links.json +47 -0
  62. package/lib/schema/schema/widget/recent_posts.json +13 -0
  63. package/lib/schema/schema/widget/subscribe_email.json +22 -0
  64. package/lib/schema/schema/widget/tags.json +30 -0
  65. package/lib/schema/schema/widget/toc.json +31 -0
  66. package/lib/schema/search/insight.json +6 -0
  67. package/lib/schema/widget/tags.json +17 -0
  68. package/lib/view/comment/changyan.js +2 -2
  69. package/lib/view/comment/disqus.js +2 -2
  70. package/lib/view/comment/disqusjs.js +2 -2
  71. package/lib/view/comment/facebook.js +2 -2
  72. package/lib/view/comment/gitalk.js +2 -2
  73. package/lib/view/comment/gitment.js +2 -2
  74. package/lib/view/comment/isso.js +2 -2
  75. package/lib/view/comment/livere.js +2 -2
  76. package/lib/view/comment/twikoo.js +113 -0
  77. package/lib/view/comment/utterances.js +3 -3
  78. package/lib/view/comment/valine.js +3 -3
  79. package/lib/view/comment/waline.js +63 -52
  80. package/lib/view/common/article_media.js +2 -2
  81. package/lib/view/donate/afdian.js +2 -2
  82. package/lib/view/donate/alipay.js +2 -2
  83. package/lib/view/donate/buymeacoffee.js +2 -2
  84. package/lib/view/donate/patreon.js +2 -2
  85. package/lib/view/donate/paypal.js +2 -2
  86. package/lib/view/donate/wechat.js +2 -2
  87. package/lib/view/misc/article_licensing.js +2 -2
  88. package/lib/view/misc/meta.js +2 -2
  89. package/lib/view/misc/open_graph.js +12 -4
  90. package/lib/view/misc/paginator.js +2 -2
  91. package/lib/view/misc/structured_data.js +2 -2
  92. package/lib/view/misc/web_app.js +2 -2
  93. package/lib/view/plugin/baidu_analytics.js +2 -2
  94. package/lib/view/plugin/bing_webmaster.js +2 -2
  95. package/lib/view/plugin/busuanzi.js +2 -2
  96. package/lib/view/plugin/cnzz.js +2 -2
  97. package/lib/view/plugin/cookie_consent.js +2 -2
  98. package/lib/view/plugin/gallery.js +2 -2
  99. package/lib/view/plugin/google_analytics.js +2 -2
  100. package/lib/view/plugin/hotjar.js +2 -2
  101. package/lib/view/plugin/katex.js +2 -2
  102. package/lib/view/plugin/mathjax.js +2 -2
  103. package/lib/view/plugin/outdated_browser.js +2 -2
  104. package/lib/view/plugin/progressbar.js +2 -2
  105. package/lib/view/plugin/statcounter.js +2 -2
  106. package/lib/view/plugin/twitter_conversion_tracking.js +2 -2
  107. package/lib/view/search/algolia.js +2 -2
  108. package/lib/view/search/baidu.js +2 -2
  109. package/lib/view/search/google_cse.js +2 -2
  110. package/lib/view/search/insight.js +2 -2
  111. package/lib/view/share/addthis.js +2 -2
  112. package/lib/view/share/addtoany.js +2 -2
  113. package/lib/view/share/bdshare.js +2 -2
  114. package/lib/view/share/sharejs.js +2 -2
  115. package/lib/view/share/sharethis.js +2 -2
  116. package/lib/view/widget/adsense.js +2 -2
  117. package/lib/view/widget/archives.js +2 -2
  118. package/lib/view/widget/categories.js +2 -2
  119. package/lib/view/widget/followit.js +2 -2
  120. package/lib/view/widget/links.js +2 -2
  121. package/lib/view/widget/recent_posts.js +2 -2
  122. package/lib/view/widget/subscribe_email.js +2 -2
  123. package/lib/view/widget/tags.js +16 -15
  124. package/lib/view/widget/toc.js +2 -2
  125. package/package.json +10 -11
@@ -43,11 +43,18 @@ module.exports = function (hexo) {
43
43
  }
44
44
 
45
45
  const site = {
46
- pages: locals.pages.map(mapPost),
47
46
  posts: locals.posts.map(mapPost),
48
47
  tags: locals.tags.map(mapTag),
49
48
  categories: locals.categories.map(mapTag)
50
49
  };
50
+ const index_pages = ((this.theme.config || {}).search || {}).index_pages;
51
+
52
+ if (index_pages === false) {
53
+ site.pages = [];
54
+ } else {
55
+ site.pages = locals.pages.map(mapPost);
56
+ }
57
+
51
58
  return {
52
59
  path: '/content.json',
53
60
  data: JSON.stringify(site)
@@ -79,4 +79,20 @@ test('Export assets file from asset folder', async () => {
79
79
  expect(data.tags.length).toBe(2);
80
80
  expect(data.tags.find(tag => tag.name === 'tag1' && tag.slug === 'tag1' && tag.link.includes('tag1'))).not.toBeUndefined();
81
81
  expect(data.tags.find(tag => tag.name === 'tag2' && tag.slug === 'tag2' && tag.link.includes('tag2'))).not.toBeUndefined();
82
+ });
83
+ test('Exclude pages from index when `index_pages` is false', async () => {
84
+ const locals = hexo.locals.toObject();
85
+ locals.config = hexo.config;
86
+ locals.posts = posts;
87
+ locals.pages = pages;
88
+ locals.categories = categories;
89
+ locals.tags = tags;
90
+ hexo.theme.config.search = {
91
+ index_pages: false
92
+ };
93
+ const generator = hexo.extend.generator.get('insight').bind(hexo);
94
+ const result = await generator(locals);
95
+ const data = JSON.parse(result.data);
96
+ expect(data.posts.length).toBe(2);
97
+ expect(data.pages.length).toBe(0);
82
98
  });
@@ -12,9 +12,7 @@ const PROVIDERS = {
12
12
  cdnjs: '[cdnjs]https://cdnjs.cloudflare.com/ajax/libs/${ package }/${ version }/${ filename }',
13
13
  loli: '[cdnjs]https://cdnjs.loli.net/ajax/libs/${ package }/${ version }/${ filename }',
14
14
  jsdelivr: 'https://cdn.jsdelivr.net/npm/${ package }@${ version }/${ filename }',
15
- unpkg: 'https://unpkg.com/${ package }@${ version }/${ filename }',
16
- bootcdn: '[cdnjs]https://cdn.bootcdn.net/ajax/libs/${ package }/${ version }/${ filename }',
17
- '75cdn': '[cdnjs]https://lib.baomitu.com/${ package }/${ version }/${ filename }'
15
+ unpkg: 'https://unpkg.com/${ package }@${ version }/${ filename }'
18
16
  },
19
17
  FONT: {
20
18
  google: 'https://fonts.googleapis.com/${ type }?family=${ fontname }',
@@ -23,10 +21,8 @@ const PROVIDERS = {
23
21
  ustc: 'https://fonts.lug.ustc.edu.cn/${ type }?family=${ fontname }'
24
22
  },
25
23
  ICON: {
26
- loli: 'https://cdnjs.loli.net/ajax/libs/font-awesome/5.15.2/css/all.min.css',
27
- fontawesome: 'https://use.fontawesome.com/releases/v5.15.2/css/all.css',
28
- bootcdn: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.3/css/all.min.css',
29
- '75cdn': 'https://lib.baomitu.com/font-awesome/5.12.1/css/all.min.css'
24
+ loli: 'https://cdnjs.loli.net/ajax/libs/font-awesome/6.0.0/css/all.min.css',
25
+ fontawesome: 'https://use.fontawesome.com/releases/v6.0.0/css/all.css'
30
26
  }
31
27
  };
32
28
  /**
@@ -45,11 +41,8 @@ const CDNJS_FIXTURES = {
45
41
  katex: (ver, fname) => ['KaTeX', ver, fname],
46
42
  'pace-js': (ver, fname) => ['pace', ver, fname],
47
43
  clipboard: (ver, fname) => ['clipboard.js', ver, fname],
48
- // disqusjs is not hosted on CDN.js
49
- disqusjs: (ver, fname) => [],
50
44
  cookieconsent: (ver, fname) => ['cookieconsent', ver, fname.startsWith('build/') ? fname.substr(6) : fname],
51
- // waline is not hosted on CDN.js
52
- '@waline/client': (ver, fname) => []
45
+ '@waline/client': (ver, fname) => ['waline', ver, fname]
53
46
  };
54
47
  const UNPKG_FIXTURES = {
55
48
  mathjax: (ver, fname) => ['mathjax', ver, fname.indexOf('.min.') > -1 ? fname.replace(/\.min\./gi, '.') : fname],
@@ -17,59 +17,45 @@ describe('Get JavaScript library URL', () => {
17
17
  let cases;
18
18
  beforeEach(async () => {
19
19
  const cdn = hexo.extend.helper.get('cdn').bind(hexo);
20
- cases = [() => cdn('jquery', '3.0.0', 'dist/jquery.min.js'), () => cdn('moment', '2.24.0', 'min/moment.min.js'), () => cdn('outdatedbrowser', '1.1.5', 'outdatedbrowser/outdatedbrowser.min.js'), () => cdn('highlight.js', '9.18.1', 'styles/a11y-dark.css'), () => cdn('mathjax', '2.7.6', 'unpacked/MathJax.min.js'), () => cdn('pace-js', '1.0.2', 'pace.min.js'), () => cdn('katex', '0.11.1', 'dist/katex.min.js'), () => cdn('clipboard', '2.0.6', 'dist/clipboard.min.js'), () => cdn('disqusjs', '1.2.6', 'dist/disqus.min.js'), () => cdn('algoliasearch', '4.0.3', 'dist/algoliasearch-lite.umd.js'), () => cdn('instantsearch.js', '4.3.1', 'dist/instantsearch.production.min.js'), () => cdn('cookieconsent', '3.1.1', 'build/cookieconsent.min.js'), () => cdn('@waline/client', '1.3.1', 'dist/Waline.min.js'), () => cdn('example', '1.0.0', 'example.js')];
20
+ cases = [() => cdn('jquery', '3.0.0', 'dist/jquery.min.js'), () => cdn('moment', '2.24.0', 'min/moment.min.js'), () => cdn('outdatedbrowser', '1.1.5', 'outdatedbrowser/outdatedbrowser.min.js'), () => cdn('highlight.js', '9.18.1', 'styles/a11y-dark.css'), () => cdn('mathjax', '2.7.6', 'unpacked/MathJax.min.js'), () => cdn('pace-js', '1.0.2', 'pace.min.js'), () => cdn('katex', '0.11.1', 'dist/katex.min.js'), () => cdn('clipboard', '2.0.6', 'dist/clipboard.min.js'), () => cdn('disqusjs', '1.3.0', 'dist/disqus.min.js'), () => cdn('algoliasearch', '4.0.3', 'dist/algoliasearch-lite.umd.js'), () => cdn('instantsearch.js', '4.3.1', 'dist/instantsearch.production.min.js'), () => cdn('cookieconsent', '3.1.1', 'build/cookieconsent.min.js'), () => cdn('@waline/client', '2.6.3', 'dist/waline.js'), () => cdn('twikoo', '1.6.6', 'dist/twikoo.all.min.js'), () => cdn('example', '1.0.0', 'example.js')];
21
21
  });
22
22
  test('jsdelivr', () => {
23
- const expected = ['https://cdn.jsdelivr.net/npm/jquery@3.0.0/dist/jquery.min.js', 'https://cdn.jsdelivr.net/npm/moment@2.24.0/min/moment.min.js', 'https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js', 'https://cdn.jsdelivr.net/npm/highlight.js@9.18.1/styles/a11y-dark.css', 'https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.min.js', 'https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js', 'https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js', 'https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js', 'https://cdn.jsdelivr.net/npm/disqusjs@1.2.6/dist/disqus.min.js', 'https://cdn.jsdelivr.net/npm/algoliasearch@4.0.3/dist/algoliasearch-lite.umd.js', 'https://cdn.jsdelivr.net/npm/instantsearch.js@4.3.1/dist/instantsearch.production.min.js', 'https://cdn.jsdelivr.net/npm/cookieconsent@3.1.1/build/cookieconsent.min.js', 'https://cdn.jsdelivr.net/npm/@waline/client@1.3.1/dist/Waline.min.js', 'https://cdn.jsdelivr.net/npm/example@1.0.0/example.js'];
23
+ const expected = ['https://cdn.jsdelivr.net/npm/jquery@3.0.0/dist/jquery.min.js', 'https://cdn.jsdelivr.net/npm/moment@2.24.0/min/moment.min.js', 'https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js', 'https://cdn.jsdelivr.net/npm/highlight.js@9.18.1/styles/a11y-dark.css', 'https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.min.js', 'https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js', 'https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js', 'https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js', 'https://cdn.jsdelivr.net/npm/disqusjs@1.3.0/dist/disqus.min.js', 'https://cdn.jsdelivr.net/npm/algoliasearch@4.0.3/dist/algoliasearch-lite.umd.js', 'https://cdn.jsdelivr.net/npm/instantsearch.js@4.3.1/dist/instantsearch.production.min.js', 'https://cdn.jsdelivr.net/npm/cookieconsent@3.1.1/build/cookieconsent.min.js', 'https://cdn.jsdelivr.net/npm/@waline/client@2.6.3/dist/waline.js', 'https://cdn.jsdelivr.net/npm/twikoo@1.6.6/dist/twikoo.all.min.js', 'https://cdn.jsdelivr.net/npm/example@1.0.0/example.js'];
24
24
  cases.forEach((func, i) => expect(func()).toBe(expected[i]));
25
25
  });
26
26
  test('unpkg', () => {
27
27
  hexo.config.providers = {
28
28
  cdn: 'unpkg'
29
29
  };
30
- const expected = ['https://unpkg.com/jquery@3.0.0/dist/jquery.min.js', 'https://unpkg.com/moment@2.24.0/min/moment.min.js', 'https://unpkg.com/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js', 'https://unpkg.com/highlight.js@9.18.1/styles/a11y-dark.css', 'https://unpkg.com/mathjax@2.7.6/unpacked/MathJax.js', 'https://unpkg.com/pace-js@1.0.2/pace.min.js', 'https://unpkg.com/katex@0.11.1/dist/katex.min.js', 'https://unpkg.com/clipboard@2.0.6/dist/clipboard.min.js', 'https://unpkg.com/disqusjs@1.2.6/dist/disqus.js', 'https://unpkg.com/algoliasearch@4.0.3/dist/algoliasearch-lite.umd.js', 'https://unpkg.com/instantsearch.js@4.3.1/dist/instantsearch.production.min.js', 'https://unpkg.com/cookieconsent@3.1.1/build/cookieconsent.min.js', 'https://unpkg.com/@waline/client@1.3.1/dist/Waline.min.js', 'https://unpkg.com/example@1.0.0/example.js'];
30
+ const expected = ['https://unpkg.com/jquery@3.0.0/dist/jquery.min.js', 'https://unpkg.com/moment@2.24.0/min/moment.min.js', 'https://unpkg.com/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js', 'https://unpkg.com/highlight.js@9.18.1/styles/a11y-dark.css', 'https://unpkg.com/mathjax@2.7.6/unpacked/MathJax.js', 'https://unpkg.com/pace-js@1.0.2/pace.min.js', 'https://unpkg.com/katex@0.11.1/dist/katex.min.js', 'https://unpkg.com/clipboard@2.0.6/dist/clipboard.min.js', 'https://unpkg.com/disqusjs@1.3.0/dist/disqus.js', 'https://unpkg.com/algoliasearch@4.0.3/dist/algoliasearch-lite.umd.js', 'https://unpkg.com/instantsearch.js@4.3.1/dist/instantsearch.production.min.js', 'https://unpkg.com/cookieconsent@3.1.1/build/cookieconsent.min.js', 'https://unpkg.com/@waline/client@2.6.3/dist/waline.js', 'https://unpkg.com/twikoo@1.6.6/dist/twikoo.all.min.js', 'https://unpkg.com/example@1.0.0/example.js'];
31
31
  cases.forEach((func, i) => expect(func()).toBe(expected[i]));
32
32
  });
33
33
  test('cdnjs', () => {
34
34
  hexo.config.providers = {
35
35
  cdn: 'cdnjs'
36
36
  };
37
- const expected = ['https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/a11y-dark.min.css', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js', 'https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js', 'https://cdn.jsdelivr.net/npm/disqusjs@1.2.6/dist/disqus.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/algoliasearch/4.0.3/algoliasearch-lite.umd.js', 'https://cdnjs.cloudflare.com/ajax/libs/instantsearch.js/4.3.1/instantsearch.production.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.js', 'https://cdn.jsdelivr.net/npm/@waline/client@1.3.1/dist/Waline.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/example/1.0.0/example.js'];
37
+ const expected = ['https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/a11y-dark.min.css', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js', 'https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/disqusjs/1.3.0/disqus.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/algoliasearch/4.0.3/algoliasearch-lite.umd.js', 'https://cdnjs.cloudflare.com/ajax/libs/instantsearch.js/4.3.1/instantsearch.production.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/waline/2.6.3/waline.js', 'https://cdnjs.cloudflare.com/ajax/libs/twikoo/1.6.6/twikoo.all.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/example/1.0.0/example.js'];
38
38
  cases.forEach((func, i) => expect(func()).toBe(expected[i]));
39
39
  });
40
40
  test('loli', () => {
41
41
  hexo.config.providers = {
42
42
  cdn: 'loli'
43
43
  };
44
- const expected = ['https://cdnjs.loli.net/ajax/libs/jquery/3.0.0/jquery.min.js', 'https://cdnjs.loli.net/ajax/libs/moment.js/2.24.0/moment.min.js', 'https://cdnjs.loli.net/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js', 'https://cdnjs.loli.net/ajax/libs/highlight.js/9.18.1/styles/a11y-dark.min.css', 'https://cdnjs.loli.net/ajax/libs/mathjax/2.7.6/MathJax.js', 'https://cdnjs.loli.net/ajax/libs/pace/1.0.2/pace.min.js', 'https://cdnjs.loli.net/ajax/libs/KaTeX/0.11.1/katex.min.js', 'https://cdnjs.loli.net/ajax/libs/clipboard.js/2.0.6/clipboard.min.js', 'https://cdn.jsdelivr.net/npm/disqusjs@1.2.6/dist/disqus.min.js', 'https://cdnjs.loli.net/ajax/libs/algoliasearch/4.0.3/algoliasearch-lite.umd.js', 'https://cdnjs.loli.net/ajax/libs/instantsearch.js/4.3.1/instantsearch.production.min.js', 'https://cdnjs.loli.net/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.js', 'https://cdn.jsdelivr.net/npm/@waline/client@1.3.1/dist/Waline.min.js', 'https://cdnjs.loli.net/ajax/libs/example/1.0.0/example.js'];
45
- cases.forEach((func, i) => expect(func()).toBe(expected[i]));
46
- });
47
- test('bootcdn', () => {
48
- hexo.config.providers = {
49
- cdn: 'bootcdn'
50
- };
51
- const expected = ['https://cdn.bootcdn.net/ajax/libs/jquery/3.0.0/jquery.min.js', 'https://cdn.bootcdn.net/ajax/libs/moment.js/2.24.0/moment.min.js', 'https://cdn.bootcdn.net/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js', 'https://cdn.bootcdn.net/ajax/libs/highlight.js/9.18.1/styles/a11y-dark.min.css', 'https://cdn.bootcdn.net/ajax/libs/mathjax/2.7.6/MathJax.js', 'https://cdn.bootcdn.net/ajax/libs/pace/1.0.2/pace.min.js', 'https://cdn.bootcdn.net/ajax/libs/KaTeX/0.11.1/katex.min.js', 'https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.6/clipboard.min.js', 'https://cdn.jsdelivr.net/npm/disqusjs@1.2.6/dist/disqus.min.js', 'https://cdn.bootcdn.net/ajax/libs/algoliasearch/4.0.3/algoliasearch-lite.umd.js', 'https://cdn.bootcdn.net/ajax/libs/instantsearch.js/4.3.1/instantsearch.production.min.js', 'https://cdn.bootcdn.net/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.js', 'https://cdn.jsdelivr.net/npm/@waline/client@1.3.1/dist/Waline.min.js', 'https://cdn.bootcdn.net/ajax/libs/example/1.0.0/example.js'];
52
- cases.forEach((func, i) => expect(func()).toBe(expected[i]));
53
- });
54
- test('75cdn', () => {
55
- hexo.config.providers = {
56
- cdn: '75cdn'
57
- };
58
- const expected = ['https://lib.baomitu.com/jquery/3.0.0/jquery.min.js', 'https://lib.baomitu.com/moment.js/2.24.0/moment.min.js', 'https://lib.baomitu.com/outdated-browser/1.1.5/outdatedbrowser.min.js', 'https://lib.baomitu.com/highlight.js/9.18.1/styles/a11y-dark.min.css', 'https://lib.baomitu.com/mathjax/2.7.6/MathJax.js', 'https://lib.baomitu.com/pace/1.0.2/pace.min.js', 'https://lib.baomitu.com/KaTeX/0.11.1/katex.min.js', 'https://lib.baomitu.com/clipboard.js/2.0.6/clipboard.min.js', 'https://cdn.jsdelivr.net/npm/disqusjs@1.2.6/dist/disqus.min.js', 'https://lib.baomitu.com/algoliasearch/4.0.3/algoliasearch-lite.umd.js', 'https://lib.baomitu.com/instantsearch.js/4.3.1/instantsearch.production.min.js', 'https://lib.baomitu.com/cookieconsent/3.1.1/cookieconsent.min.js', 'https://cdn.jsdelivr.net/npm/@waline/client@1.3.1/dist/Waline.min.js', 'https://lib.baomitu.com/example/1.0.0/example.js'];
44
+ const expected = ['https://cdnjs.loli.net/ajax/libs/jquery/3.0.0/jquery.min.js', 'https://cdnjs.loli.net/ajax/libs/moment.js/2.24.0/moment.min.js', 'https://cdnjs.loli.net/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js', 'https://cdnjs.loli.net/ajax/libs/highlight.js/9.18.1/styles/a11y-dark.min.css', 'https://cdnjs.loli.net/ajax/libs/mathjax/2.7.6/MathJax.js', 'https://cdnjs.loli.net/ajax/libs/pace/1.0.2/pace.min.js', 'https://cdnjs.loli.net/ajax/libs/KaTeX/0.11.1/katex.min.js', 'https://cdnjs.loli.net/ajax/libs/clipboard.js/2.0.6/clipboard.min.js', 'https://cdnjs.loli.net/ajax/libs/disqusjs/1.3.0/disqus.min.js', 'https://cdnjs.loli.net/ajax/libs/algoliasearch/4.0.3/algoliasearch-lite.umd.js', 'https://cdnjs.loli.net/ajax/libs/instantsearch.js/4.3.1/instantsearch.production.min.js', 'https://cdnjs.loli.net/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.js', 'https://cdnjs.loli.net/ajax/libs/waline/2.6.3/waline.js', 'https://cdnjs.loli.net/ajax/libs/twikoo/1.6.6/twikoo.all.min.js', 'https://cdnjs.loli.net/ajax/libs/example/1.0.0/example.js'];
59
45
  cases.forEach((func, i) => expect(func()).toBe(expected[i]));
60
46
  });
61
47
  test('Custom CDN', () => {
62
48
  hexo.config.providers = {
63
49
  cdn: 'https://my.cdn/${ package }@${ version }/${ filename }'
64
50
  };
65
- const expected = ['https://my.cdn/jquery@3.0.0/dist/jquery.min.js', 'https://my.cdn/moment@2.24.0/min/moment.min.js', 'https://my.cdn/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js', 'https://my.cdn/highlight.js@9.18.1/styles/a11y-dark.css', 'https://my.cdn/mathjax@2.7.6/unpacked/MathJax.min.js', 'https://my.cdn/pace-js@1.0.2/pace.min.js', 'https://my.cdn/katex@0.11.1/dist/katex.min.js', 'https://my.cdn/clipboard@2.0.6/dist/clipboard.min.js', 'https://my.cdn/disqusjs@1.2.6/dist/disqus.min.js', 'https://my.cdn/algoliasearch@4.0.3/dist/algoliasearch-lite.umd.js', 'https://my.cdn/instantsearch.js@4.3.1/dist/instantsearch.production.min.js', 'https://my.cdn/cookieconsent@3.1.1/build/cookieconsent.min.js', 'https://my.cdn/@waline/client@1.3.1/dist/Waline.min.js', 'https://my.cdn/example@1.0.0/example.js'];
51
+ const expected = ['https://my.cdn/jquery@3.0.0/dist/jquery.min.js', 'https://my.cdn/moment@2.24.0/min/moment.min.js', 'https://my.cdn/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js', 'https://my.cdn/highlight.js@9.18.1/styles/a11y-dark.css', 'https://my.cdn/mathjax@2.7.6/unpacked/MathJax.min.js', 'https://my.cdn/pace-js@1.0.2/pace.min.js', 'https://my.cdn/katex@0.11.1/dist/katex.min.js', 'https://my.cdn/clipboard@2.0.6/dist/clipboard.min.js', 'https://my.cdn/disqusjs@1.3.0/dist/disqus.min.js', 'https://my.cdn/algoliasearch@4.0.3/dist/algoliasearch-lite.umd.js', 'https://my.cdn/instantsearch.js@4.3.1/dist/instantsearch.production.min.js', 'https://my.cdn/cookieconsent@3.1.1/build/cookieconsent.min.js', 'https://my.cdn/@waline/client@2.6.3/dist/waline.js', 'https://my.cdn/twikoo@1.6.6/dist/twikoo.all.min.js', 'https://my.cdn/example@1.0.0/example.js'];
66
52
  cases.forEach((func, i) => expect(func()).toBe(expected[i]));
67
53
  });
68
54
  test('Custom CDN.js-style CDN', () => {
69
55
  hexo.config.providers = {
70
56
  cdn: '[cdnjs]https://my.cdn/ajax/libs/${ package }/${ version }/${ filename }'
71
57
  };
72
- const expected = ['https://my.cdn/ajax/libs/jquery/3.0.0/jquery.min.js', 'https://my.cdn/ajax/libs/moment.js/2.24.0/moment.min.js', 'https://my.cdn/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js', 'https://my.cdn/ajax/libs/highlight.js/9.18.1/styles/a11y-dark.min.css', 'https://my.cdn/ajax/libs/mathjax/2.7.6/MathJax.js', 'https://my.cdn/ajax/libs/pace/1.0.2/pace.min.js', 'https://my.cdn/ajax/libs/KaTeX/0.11.1/katex.min.js', 'https://my.cdn/ajax/libs/clipboard.js/2.0.6/clipboard.min.js', 'https://cdn.jsdelivr.net/npm/disqusjs@1.2.6/dist/disqus.min.js', 'https://my.cdn/ajax/libs/algoliasearch/4.0.3/algoliasearch-lite.umd.js', 'https://my.cdn/ajax/libs/instantsearch.js/4.3.1/instantsearch.production.min.js', 'https://my.cdn/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.js', 'https://cdn.jsdelivr.net/npm/@waline/client@1.3.1/dist/Waline.min.js', 'https://my.cdn/ajax/libs/example/1.0.0/example.js'];
58
+ const expected = ['https://my.cdn/ajax/libs/jquery/3.0.0/jquery.min.js', 'https://my.cdn/ajax/libs/moment.js/2.24.0/moment.min.js', 'https://my.cdn/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js', 'https://my.cdn/ajax/libs/highlight.js/9.18.1/styles/a11y-dark.min.css', 'https://my.cdn/ajax/libs/mathjax/2.7.6/MathJax.js', 'https://my.cdn/ajax/libs/pace/1.0.2/pace.min.js', 'https://my.cdn/ajax/libs/KaTeX/0.11.1/katex.min.js', 'https://my.cdn/ajax/libs/clipboard.js/2.0.6/clipboard.min.js', 'https://my.cdn/ajax/libs/disqusjs/1.3.0/disqus.min.js', 'https://my.cdn/ajax/libs/algoliasearch/4.0.3/algoliasearch-lite.umd.js', 'https://my.cdn/ajax/libs/instantsearch.js/4.3.1/instantsearch.production.min.js', 'https://my.cdn/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.js', 'https://my.cdn/ajax/libs/waline/2.6.3/waline.js', 'https://my.cdn/ajax/libs/twikoo/1.6.6/twikoo.all.min.js', 'https://my.cdn/ajax/libs/example/1.0.0/example.js'];
73
59
  cases.forEach((func, i) => expect(func()).toBe(expected[i]));
74
60
  });
75
61
  });
@@ -125,28 +111,14 @@ describe('Get icon font URL', () => {
125
111
  hexo.config.providers = {
126
112
  iconcdn: 'fontawesome'
127
113
  };
128
- const expected = ['https://use.fontawesome.com/releases/v5.15.2/css/all.css'];
114
+ const expected = ['https://use.fontawesome.com/releases/v6.0.0/css/all.css'];
129
115
  cases.forEach((func, i) => expect(func()).toBe(expected[i]));
130
116
  });
131
117
  test('loli', () => {
132
118
  hexo.config.providers = {
133
119
  iconcdn: 'loli'
134
120
  };
135
- const expected = ['https://cdnjs.loli.net/ajax/libs/font-awesome/5.15.2/css/all.min.css'];
136
- cases.forEach((func, i) => expect(func()).toBe(expected[i]));
137
- });
138
- test('bootcdn', () => {
139
- hexo.config.providers = {
140
- iconcdn: 'bootcdn'
141
- };
142
- const expected = ['https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.3/css/all.min.css'];
143
- cases.forEach((func, i) => expect(func()).toBe(expected[i]));
144
- });
145
- test('75cdn', () => {
146
- hexo.config.providers = {
147
- iconcdn: '75cdn'
148
- };
149
- const expected = ['https://lib.baomitu.com/font-awesome/5.12.1/css/all.min.css'];
121
+ const expected = ['https://cdnjs.loli.net/ajax/libs/font-awesome/6.0.0/css/all.min.css'];
150
122
  cases.forEach((func, i) => expect(func()).toBe(expected[i]));
151
123
  });
152
124
  test('Custom web font CDN', () => {
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Register custom Hexo tag {% message %}.
3
+ * @module hexo/tag/message
4
+ */
5
+
6
+ /**
7
+ * Register custom Hexo tag {% message %}.
8
+ * <p>
9
+ * This tag is rendered as a Bulma message box.
10
+ *
11
+ * <h5>Tag Parameters:<h5>
12
+ * <table class="params">
13
+ * <tr>
14
+ * <th>Name</th>
15
+ * <th>Type</th>
16
+ * <th class="description">Description</th>
17
+ * </tr>
18
+ * <tr>
19
+ * <td class="name"><code>color</code></td>
20
+ * <td class="type"><span class="param-type"><code>string</code></span></td>
21
+ * <td class="description">[Optional] Color of the message. Available values are: dark, primary, link, info, success, warning, danger.</td>
22
+ * </tr>
23
+ * <tr>
24
+ * <td class="name"><code>icon</code></td>
25
+ * <td class="type"><span class="param-type"><code>string</code></span></td>
26
+ * <td class="description">[Optional] Icon shown in the message header. Use FontAwesome icon class name for this field.</td>
27
+ * </tr>
28
+ * <tr>
29
+ * <td class="name"><code>title</code></td>
30
+ * <td class="type"><span class="param-type"><code>string</code></span></td>
31
+ * <td class="description">[Optional] Message title in the message header. Markdown is supported.</td>
32
+ * </tr>
33
+ * <tr>
34
+ * <td class="name"><code>size</code></td>
35
+ * <td class="type"><span class="param-type"><code>string</code></span></td>
36
+ * <td class="description last">[Optional] Size of the message box. Available values are: small, medium, large. Default size is normal.</td>
37
+ * </tr>
38
+ * </table>
39
+ *
40
+ * @see https://bulma.io/documentation/components/message/.
41
+ *
42
+ * @param {Hexo} hexo The Hexo instance.
43
+ *
44
+ * @example
45
+ * {% message color:warning 'icon:fas fa-info-circle' 'title:*ATTENTION*' size:small %}
46
+ * **This is a warning message.**
47
+ * {% endmessage %}
48
+ */
49
+ module.exports = function (hexo) {
50
+ function processTag(options, content) {
51
+ let icon = '';
52
+ let title = '';
53
+ let classes = '';
54
+ let header = '';
55
+
56
+ for (const option of options) {
57
+ const [key, value] = option.split(':');
58
+
59
+ switch (key) {
60
+ case 'size':
61
+ classes += ` is-${value}`;
62
+ break;
63
+
64
+ case 'color':
65
+ classes += ` is-${value}`;
66
+ break;
67
+
68
+ case 'icon':
69
+ icon = `<i class="${value} mr-2"></i>`;
70
+ break;
71
+
72
+ case 'title':
73
+ title = value;
74
+ break;
75
+ }
76
+ }
77
+
78
+ if (icon !== '' || title !== '') {
79
+ const inner = hexo.render.renderSync({
80
+ text: icon + title,
81
+ engine: 'markdown'
82
+ });
83
+ header = `<div class="message-header">${inner}</div>`;
84
+ }
85
+
86
+ return `<article class="message${classes}">
87
+ ${header}
88
+ <div class="message-body">
89
+ ${hexo.render.renderSync({
90
+ text: content,
91
+ engine: 'markdown'
92
+ })}
93
+ </div>
94
+ </article>`;
95
+ }
96
+
97
+ hexo.extend.tag.register('message', processTag, {
98
+ ends: true
99
+ });
100
+ };
@@ -0,0 +1,79 @@
1
+ const {
2
+ join
3
+ } = require('path');
4
+
5
+ const Hexo = require('hexo');
6
+
7
+ const cheerio = require('cheerio');
8
+
9
+ const {
10
+ minify
11
+ } = require('html-minifier');
12
+
13
+ const register = require('./message');
14
+
15
+ const rootDir = join(__dirname, '../../../fixture/site');
16
+ const hexo = new Hexo(rootDir, {
17
+ silent: true
18
+ });
19
+ const cheerioOptions = {
20
+ xml: {
21
+ normalizeWhitespace: true
22
+ }
23
+ };
24
+ const minifierOptions = {
25
+ collapseWhitespace: true,
26
+ conservativeCollapse: true,
27
+ keepClosingSlash: true
28
+ };
29
+ beforeAll(async () => {
30
+ await hexo.init();
31
+ await hexo.load();
32
+ register(hexo);
33
+ await hexo.loadPlugin(require.resolve('hexo-renderer-marked'));
34
+ });
35
+ test('create default message', async () => {
36
+ const render = hexo.extend.tag.render.bind(hexo.extend.tag);
37
+ let source = '{% message %}**content**{% endmessage %}';
38
+ let actual = cheerio.load(await render(source), cheerioOptions, false).html();
39
+ expect(minify(actual, minifierOptions)).toEqual('<article class="message"> <div class="message-body"> ' + '<p><strong>content</strong></p> </div> </article>');
40
+ source = '{% message %}\n# title\n{% endmessage %}';
41
+ actual = cheerio.load(await render(source), cheerioOptions, false).html();
42
+ expect(minify(actual, minifierOptions)).toEqual('<article class="message"> <div class="message-body"> ' + '<h1 id="title"><a href="#title" class="headerlink" title="title"/>title</h1> ' + '</div> </article>');
43
+ });
44
+ test('create message with different colors', async () => {
45
+ const render = hexo.extend.tag.render.bind(hexo.extend.tag);
46
+
47
+ for (const color of ['dark', 'primary', 'link', 'info', 'success', 'warning', 'danger']) {
48
+ const source = `{% message color:${color} %}content{% endmessage %}`;
49
+ const actual = cheerio.load(await render(source), cheerioOptions, false).html();
50
+ expect(minify(actual, minifierOptions)).toEqual(`<article class="message is-${color}"> <div class="message-body"> <p>content</p> ` + '</div> </article>');
51
+ }
52
+ });
53
+ test('create message with different sizes', async () => {
54
+ const render = hexo.extend.tag.render.bind(hexo.extend.tag);
55
+
56
+ for (const size of ['small', 'medium', 'large']) {
57
+ const source = `{% message size:${size} %}content{% endmessage %}`;
58
+ const actual = cheerio.load(await render(source), cheerioOptions, false).html();
59
+ expect(minify(actual, minifierOptions)).toEqual(`<article class="message is-${size}"> <div class="message-body"> <p>content</p> ` + '</div> </article>');
60
+ }
61
+ });
62
+ test('create message with an icon', async () => {
63
+ const render = hexo.extend.tag.render.bind(hexo.extend.tag);
64
+ const source = '{% message "icon:fas fas-file" %}content{% endmessage %}';
65
+ const actual = cheerio.load(await render(source), cheerioOptions, false).html();
66
+ expect(minify(actual, minifierOptions)).toEqual('<article class="message"> <div class="message-header"><p>' + '<i class="fas fas-file mr-2"/></p> </div> <div class="message-body"> <p>content</p> ' + '</div> </article>');
67
+ });
68
+ test('create message with a title', async () => {
69
+ const render = hexo.extend.tag.render.bind(hexo.extend.tag);
70
+ const source = '{% message "title:*message title*" %}content{% endmessage %}';
71
+ const actual = cheerio.load(await render(source), cheerioOptions, false).html();
72
+ expect(minify(actual, minifierOptions)).toEqual('<article class="message"> <div class="message-header"><p>' + '<em>message title</em></p> </div> <div class="message-body"> <p>content</p> ' + '</div> </article>');
73
+ });
74
+ test('create message with all properties', async () => {
75
+ const render = hexo.extend.tag.render.bind(hexo.extend.tag);
76
+ const source = '{% message color:success size:small "icon:fas fas-file" ' + '"title:*message title*" %}content{% endmessage %}';
77
+ const actual = cheerio.load(await render(source), cheerioOptions, false).html();
78
+ expect(minify(actual, minifierOptions)).toEqual('<article class="message is-success is-small"> <div class="message-header"><p>' + '<i class="fas fas-file mr-2"/><em>message title</em></p> </div> ' + '<div class="message-body"> <p>content</p> </div> </article>');
79
+ });