hexo-component-inferno 2.0.1 → 2.0.3

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 (89) hide show
  1. package/lib/core/migrate.js +10 -28
  2. package/lib/core/migrate.test.js +10 -12
  3. package/lib/core/schema.js +33 -109
  4. package/lib/core/schema.test.js +2 -6
  5. package/lib/core/view.js +3 -10
  6. package/lib/core/view.test.js +0 -7
  7. package/lib/hexo/filter/locals.js +3 -18
  8. package/lib/hexo/filter/locals.test.js +2 -19
  9. package/lib/hexo/generator/assets.js +2 -8
  10. package/lib/hexo/generator/assets.test.js +0 -4
  11. package/lib/hexo/generator/categories.test.js +0 -3
  12. package/lib/hexo/generator/category.js +1 -6
  13. package/lib/hexo/generator/category.test.js +0 -5
  14. package/lib/hexo/generator/insight.js +1 -9
  15. package/lib/hexo/generator/insight.test.js +0 -3
  16. package/lib/hexo/generator/manifest.js +0 -3
  17. package/lib/hexo/generator/manifest.test.js +0 -3
  18. package/lib/hexo/generator/tags.test.js +0 -3
  19. package/lib/hexo/helper/cdn.js +6 -19
  20. package/lib/hexo/helper/cdn.test.js +0 -3
  21. package/lib/hexo/helper/page.test.js +0 -3
  22. package/lib/hexo/tag/message.js +0 -8
  23. package/lib/hexo/tag/message.test.js +0 -7
  24. package/lib/hexo/tag/tabs.js +3 -35
  25. package/lib/hexo/tag/tabs.test.js +0 -8
  26. package/lib/util/cache.js +0 -11
  27. package/lib/util/cache.test.js +0 -4
  28. package/lib/util/classname.js +0 -3
  29. package/lib/util/classname.test.js +0 -1
  30. package/lib/util/yaml.js +2 -7
  31. package/lib/util/yaml.test.js +0 -4
  32. package/lib/view/comment/changyan.js +12 -31
  33. package/lib/view/comment/disqus.js +11 -32
  34. package/lib/view/comment/disqusjs.js +22 -43
  35. package/lib/view/comment/facebook.js +9 -28
  36. package/lib/view/comment/gitalk.js +28 -49
  37. package/lib/view/comment/gitment.js +15 -37
  38. package/lib/view/comment/isso.js +6 -27
  39. package/lib/view/comment/livere.js +6 -27
  40. package/lib/view/comment/twikoo.js +14 -33
  41. package/lib/view/comment/utterances.js +17 -45
  42. package/lib/view/comment/valine.js +39 -60
  43. package/lib/view/comment/waline.js +45 -66
  44. package/lib/view/common/article_media.js +11 -28
  45. package/lib/view/donate/afdian.js +9 -30
  46. package/lib/view/donate/alipay.js +9 -30
  47. package/lib/view/donate/buymeacoffee.js +9 -30
  48. package/lib/view/donate/patreon.js +9 -30
  49. package/lib/view/donate/paypal.js +10 -31
  50. package/lib/view/donate/wechat.js +9 -30
  51. package/lib/view/misc/article_licensing.js +21 -43
  52. package/lib/view/misc/meta.js +7 -34
  53. package/lib/view/misc/open_graph.js +25 -67
  54. package/lib/view/misc/paginator.js +12 -36
  55. package/lib/view/misc/structured_data.js +16 -43
  56. package/lib/view/misc/web_app.js +16 -50
  57. package/lib/view/plugin/baidu_analytics.js +7 -28
  58. package/lib/view/plugin/bing_webmaster.js +7 -28
  59. package/lib/view/plugin/busuanzi.js +6 -26
  60. package/lib/view/plugin/cnzz.js +9 -30
  61. package/lib/view/plugin/cookie_consent.js +28 -49
  62. package/lib/view/plugin/gallery.js +10 -31
  63. package/lib/view/plugin/google_analytics.js +7 -28
  64. package/lib/view/plugin/hotjar.js +7 -28
  65. package/lib/view/plugin/katex.js +11 -32
  66. package/lib/view/plugin/mathjax.js +7 -28
  67. package/lib/view/plugin/outdated_browser.js +10 -31
  68. package/lib/view/plugin/progressbar.js +7 -28
  69. package/lib/view/plugin/statcounter.js +10 -31
  70. package/lib/view/plugin/twitter_conversion_tracking.js +7 -28
  71. package/lib/view/search/algolia.js +14 -35
  72. package/lib/view/search/baidu.js +9 -28
  73. package/lib/view/search/google_cse.js +10 -30
  74. package/lib/view/search/insight.js +9 -28
  75. package/lib/view/share/addthis.js +6 -27
  76. package/lib/view/share/addtoany.js +6 -25
  77. package/lib/view/share/bdshare.js +6 -25
  78. package/lib/view/share/sharejs.js +8 -27
  79. package/lib/view/share/sharethis.js +6 -27
  80. package/lib/view/widget/adsense.js +11 -32
  81. package/lib/view/widget/archives.js +26 -52
  82. package/lib/view/widget/categories.js +25 -57
  83. package/lib/view/widget/followit.js +12 -31
  84. package/lib/view/widget/links.js +27 -39
  85. package/lib/view/widget/recent_posts.js +15 -36
  86. package/lib/view/widget/subscribe_email.js +12 -31
  87. package/lib/view/widget/tags.js +16 -39
  88. package/lib/view/widget/toc.js +27 -67
  89. package/package.json +1 -1
@@ -4,10 +4,9 @@
4
4
  * @module hexo/filter/locals
5
5
  */
6
6
  const fs = require('fs');
7
-
8
7
  const path = require('path');
9
-
10
8
  const yaml = require('js-yaml');
9
+
11
10
  /**
12
11
  * Register the Hexo filter for merging theme and site config, and add all helper functions to a
13
12
  * dedicated property (<code>helper</code>) in the locals.
@@ -35,14 +34,11 @@ const yaml = require('js-yaml');
35
34
  *
36
35
  * @param {Hexo} hexo The Hexo instance.
37
36
  */
38
-
39
-
40
37
  module.exports = hexo => {
41
38
  const RESERVED_KEYS = {
42
39
  post: Object.keys(require('hexo/lib/models/post')(hexo).paths),
43
40
  page: Object.keys(require('hexo/lib/models/page')(hexo).paths)
44
41
  };
45
-
46
42
  function loadLayoutConfig(layout) {
47
43
  let config = {};
48
44
  const configInSiteDir = path.join(hexo.base_dir, '_config.' + layout + '.yml');
@@ -54,12 +50,10 @@ module.exports = hexo => {
54
50
  });
55
51
  return config;
56
52
  }
57
-
58
53
  const ALTERNATIVE_CONFIG = {
59
54
  post: loadLayoutConfig('post'),
60
55
  page: loadLayoutConfig('page')
61
56
  };
62
-
63
57
  function stripConfig(source, reservedKeys) {
64
58
  const result = {};
65
59
  Object.keys(source).filter(key => !key.startsWith('_') && !reservedKeys.includes(key) && typeof source[key] !== 'function').forEach(key => {
@@ -67,42 +61,33 @@ module.exports = hexo => {
67
61
  });
68
62
  return result;
69
63
  }
70
-
71
64
  hexo.extend.filter.register('template_locals', locals => {
72
65
  // inject helper functions
73
66
  locals.helper = {};
74
67
  const helpers = hexo.extend.helper.list();
75
-
76
68
  for (const name in helpers) {
77
69
  locals.helper[name] = helpers[name].bind(locals);
78
70
  }
79
-
80
71
  if (typeof locals.__ === 'function') {
81
72
  locals.helper.__ = locals.__;
82
73
  }
83
-
84
74
  if (typeof locals._p === 'function') {
85
75
  locals.helper._p = locals._p;
86
76
  }
87
-
88
77
  const page = locals.page;
89
-
90
78
  if (page) {
91
79
  locals.config = Object.assign({}, locals.config, locals.theme);
92
-
93
80
  if (page.layout in ALTERNATIVE_CONFIG) {
94
81
  // load alternative config if exists
95
82
  locals.config = Object.assign(locals.config, ALTERNATIVE_CONFIG[page.layout]);
96
- } // merge page configs
97
-
98
-
83
+ }
84
+ // merge page configs
99
85
  if (page.__post === true) {
100
86
  Object.assign(locals.config, stripConfig(page, RESERVED_KEYS.post));
101
87
  } else if (page.__page === true) {
102
88
  Object.assign(locals.config, stripConfig(page, RESERVED_KEYS.page));
103
89
  }
104
90
  }
105
-
106
91
  return locals;
107
92
  });
108
93
  };
@@ -1,15 +1,9 @@
1
1
  const fs = require('fs');
2
-
3
2
  const util = require('util');
4
-
5
3
  const path = require('path');
6
-
7
4
  const yaml = require('js-yaml');
8
-
9
5
  const Hexo = require('hexo');
10
-
11
6
  const register = require('./locals');
12
-
13
7
  const rootDir = path.join(__dirname, '../../../fixture/site');
14
8
  const hexo = new Hexo(rootDir, {
15
9
  silent: true
@@ -51,17 +45,14 @@ beforeAll(async () => {
51
45
  });
52
46
  test('Register all helper functions to "locals.helper"', async () => {
53
47
  const Locals = hexo._generateLocals();
54
-
55
48
  const helpers = hexo.extend.helper.list();
56
49
  const locals = await hexo.extend.filter.exec('template_locals', new Locals('about/index.html'), {
57
50
  context: hexo
58
51
  });
59
52
  expect(Object.keys(locals.helper).sort()).toEqual(Object.keys(helpers).concat('__', '_p').sort());
60
-
61
53
  for (const name in locals.helper) {
62
54
  expect(typeof locals.helper[name]).toBe('function');
63
55
  const match = regex.exec(util.inspect(locals.helper[name]));
64
-
65
56
  if (match && match.length > 1) {
66
57
  expect(match[1]).toBe(helpers[name].name);
67
58
  }
@@ -69,7 +60,6 @@ test('Register all helper functions to "locals.helper"', async () => {
69
60
  });
70
61
  test('Correctly merge theme config with site config', async () => {
71
62
  const Locals = hexo._generateLocals();
72
-
73
63
  const locals = await hexo.extend.filter.exec('template_locals', new Locals('about/index.html'), {
74
64
  context: hexo
75
65
  });
@@ -85,27 +75,22 @@ test('Correctly merge theme config with site config', async () => {
85
75
  });
86
76
  test('Page/post layout configs override theme and site configs', async () => {
87
77
  const Locals = hexo._generateLocals();
88
-
89
78
  const configs = [Object.assign({}, basePageConfig, {
90
79
  layout: 'page'
91
80
  }), Object.assign({}, basePageConfig, {
92
81
  layout: 'post'
93
82
  })];
94
-
95
83
  for (const page of configs) {
96
84
  const locals = await hexo.extend.filter.exec('template_locals', new Locals('about/index.html', page), {
97
85
  context: hexo
98
86
  });
99
- expect(locals.config.comments).toBeUndefined(); // theme page/post layout configs override ones under site root
100
-
87
+ expect(locals.config.comments).toBeUndefined();
88
+ // theme page/post layout configs override ones under site root
101
89
  const keys = ['title', 'int', 'float', 'bool', 'str', 'empty', 'arr', 'obj'];
102
-
103
90
  for (const key of keys) {
104
91
  expect(locals.config[key]).toEqual(page.layout === 'page' ? pageConfigInThemeDir[key] : postConfigInThemeDir[key]);
105
92
  }
106
-
107
93
  const keysEx = ['title_ex', 'int_ex', 'float_ex', 'bool_ex', 'str_ex', 'empty_ex', 'arr_ex', 'obj_ex'];
108
-
109
94
  for (const key of keysEx) {
110
95
  expect(locals.config[key]).toEqual(page.layout === 'page' ? pageConfigInSiteDir[key] : postConfigInSiteDir[key]);
111
96
  }
@@ -113,7 +98,6 @@ test('Page/post layout configs override theme and site configs', async () => {
113
98
  });
114
99
  test('Configs in page/post front-matter override all other config sources', async () => {
115
100
  const Locals = hexo._generateLocals();
116
-
117
101
  const configs = [Object.assign({}, basePageConfig, {
118
102
  __page: true,
119
103
  layout: 'page'
@@ -121,7 +105,6 @@ test('Configs in page/post front-matter override all other config sources', asyn
121
105
  __post: true,
122
106
  layout: 'post'
123
107
  })];
124
-
125
108
  for (const page of configs) {
126
109
  const locals = await hexo.extend.filter.exec('template_locals', new Locals('about/index.html', page), {
127
110
  context: hexo
@@ -2,10 +2,9 @@
2
2
  * Register the Hexo generator for exporting text-based asset files like JavaScript and CSS.
3
3
  * @module hexo/generator/assets
4
4
  */
5
- const fs = require('fs');
6
5
 
6
+ const fs = require('fs');
7
7
  const path = require('path');
8
-
9
8
  function walkSync(dir, filelist) {
10
9
  filelist = filelist || [];
11
10
  fs.readdirSync(dir).forEach(file => {
@@ -13,9 +12,7 @@ function walkSync(dir, filelist) {
13
12
  if (file.startsWith('.')) {
14
13
  return;
15
14
  }
16
-
17
15
  const fullpath = path.join(dir, file);
18
-
19
16
  if (fs.statSync(fullpath).isDirectory()) {
20
17
  filelist = walkSync(fullpath, filelist);
21
18
  } else {
@@ -24,6 +21,7 @@ function walkSync(dir, filelist) {
24
21
  });
25
22
  return filelist;
26
23
  }
24
+
27
25
  /**
28
26
  * Register the Hexo generator for exporting text-based asset files like JavaScript and CSS.
29
27
  * <p>
@@ -33,18 +31,14 @@ function walkSync(dir, filelist) {
33
31
  *
34
32
  * @param {Hexo} hexo The Hexo instance.
35
33
  */
36
-
37
-
38
34
  module.exports = function (hexo) {
39
35
  hexo.extend.generator.register('static_assets', locals => {
40
36
  const assetsDir = path.join(__dirname, '../../../asset');
41
37
  return walkSync(assetsDir).map(file => {
42
38
  const filepath = path.relative(assetsDir, file);
43
-
44
39
  if (fs.existsSync(path.join(hexo.theme_dir, 'source', filepath))) {
45
40
  return null;
46
41
  }
47
-
48
42
  return {
49
43
  path: '/' + filepath.replace(/\\/g, '/'),
50
44
  data: fs.readFileSync(file, {
@@ -1,15 +1,11 @@
1
1
  const {
2
2
  readFileSync
3
3
  } = require('fs');
4
-
5
4
  const {
6
5
  join
7
6
  } = require('path');
8
-
9
7
  const Hexo = require('hexo');
10
-
11
8
  const register = require('./assets');
12
-
13
9
  const rootDir = join(__dirname, '../../../fixture/site');
14
10
  const assetsDir = join(__dirname, '../../../asset');
15
11
  const hexo = new Hexo(rootDir, {
@@ -1,9 +1,6 @@
1
1
  const path = require('path');
2
-
3
2
  const Hexo = require('hexo');
4
-
5
3
  const register = require('./categories');
6
-
7
4
  const rootDir = path.join(__dirname, '../../../fixture/site');
8
5
  const hexo = new Hexo(rootDir, {
9
6
  silent: true
@@ -3,6 +3,7 @@
3
3
  * @module hexo/generator/category
4
4
  */
5
5
  const pagination = require('hexo-pagination');
6
+
6
7
  /**
7
8
  * Register the Hexo generator for generating <code>/category/</code> pages.
8
9
  * <p>
@@ -11,26 +12,20 @@ const pagination = require('hexo-pagination');
11
12
  *
12
13
  * @param {Hexo} hexo The Hexo instance.
13
14
  */
14
-
15
-
16
15
  module.exports = function (hexo) {
17
16
  hexo.extend.generator.register('category', function (locals) {
18
17
  const config = this.config;
19
18
  const paginationDir = config.pagination_dir || 'page';
20
19
  const perPage = (config.category_generator ? config.category_generator.per_page : null) || 0;
21
20
  const orderBy = (config.category_generator ? config.category_generator.order_by : null) || '-date';
22
-
23
21
  function findParent(category) {
24
22
  let parents = [];
25
-
26
23
  if (typeof category === 'object' && 'parent' in category) {
27
24
  const parent = locals.categories.filter(cat => cat._id === category.parent).first();
28
25
  parents = findParent(parent).concat([parent]);
29
26
  }
30
-
31
27
  return parents;
32
28
  }
33
-
34
29
  return locals.categories.reduce((result, category) => {
35
30
  const posts = category.posts.sort(orderBy);
36
31
  const data = pagination(category.path, posts, {
@@ -1,9 +1,6 @@
1
1
  const path = require('path');
2
-
3
2
  const Hexo = require('hexo');
4
-
5
3
  const register = require('./category');
6
-
7
4
  const rootDir = path.join(__dirname, '../../../fixture/site');
8
5
  const hexo = new Hexo(rootDir, {
9
6
  silent: true
@@ -45,11 +42,9 @@ test('Add /category/* routes and add parents array to the locals', async () => {
45
42
  const generator = hexo.extend.generator.get('category').bind(hexo);
46
43
  const result = await generator(locals);
47
44
  expect(result.length).toBe(6);
48
-
49
45
  for (const route of result) {
50
46
  expect(route.layout).toStrictEqual(['category', 'archive', 'index']);
51
47
  }
52
-
53
48
  expect(result[0].path).toBe('categories/foo/');
54
49
  expect(result[0].data.category).toBe('foo');
55
50
  expect(result[0].data.posts.length).toBe(3);
@@ -3,21 +3,18 @@
3
3
  * @module hexo/generator/insight
4
4
  */
5
5
  const util = require('hexo-util');
6
+
6
7
  /**
7
8
  * Insight search content.json generator.
8
9
  *
9
10
  * @param {Hexo} hexo The Hexo instance.
10
11
  */
11
-
12
-
13
12
  module.exports = function (hexo) {
14
13
  hexo.extend.generator.register('insight', function (locals) {
15
14
  const url_for = hexo.extend.helper.get('url_for').bind(this);
16
-
17
15
  function escape(str) {
18
16
  return util.escapeHTML(str).trim();
19
17
  }
20
-
21
18
  function minify(str) {
22
19
  return util.stripHTML(str).trim().replace(/\n/g, ' ').replace(/\s+/g, ' ').replace(/&#x([\da-fA-F]+);/g, (match, hex) => {
23
20
  return String.fromCharCode(parseInt(hex, 16));
@@ -25,7 +22,6 @@ module.exports = function (hexo) {
25
22
  return String.fromCharCode(dec);
26
23
  });
27
24
  }
28
-
29
25
  function mapPost(post) {
30
26
  return {
31
27
  title: escape(post.title),
@@ -33,7 +29,6 @@ module.exports = function (hexo) {
33
29
  link: url_for(post.path)
34
30
  };
35
31
  }
36
-
37
32
  function mapTag(tag) {
38
33
  return {
39
34
  name: escape(tag.name),
@@ -41,20 +36,17 @@ module.exports = function (hexo) {
41
36
  link: url_for(tag.path)
42
37
  };
43
38
  }
44
-
45
39
  const site = {
46
40
  posts: locals.posts.map(mapPost),
47
41
  tags: locals.tags.map(mapTag),
48
42
  categories: locals.categories.map(mapTag)
49
43
  };
50
44
  const index_pages = ((this.theme.config || {}).search || {}).index_pages;
51
-
52
45
  if (index_pages === false) {
53
46
  site.pages = [];
54
47
  } else {
55
48
  site.pages = locals.pages.map(mapPost);
56
49
  }
57
-
58
50
  return {
59
51
  path: '/content.json',
60
52
  data: JSON.stringify(site)
@@ -1,11 +1,8 @@
1
1
  const {
2
2
  join
3
3
  } = require('path');
4
-
5
4
  const Hexo = require('hexo');
6
-
7
5
  const register = require('./insight');
8
-
9
6
  const rootDir = join(__dirname, '../../../fixture/site');
10
7
  const hexo = new Hexo(rootDir, {
11
8
  silent: true
@@ -32,15 +32,12 @@ module.exports = function (hexo) {
32
32
  manifest = {}
33
33
  } = ((this.theme || {}).config || {}).head || {};
34
34
  manifest = Object.assign({}, manifest);
35
-
36
35
  if (!manifest.name) {
37
36
  manifest.name = this.config.title;
38
37
  }
39
-
40
38
  if (!manifest.start_url) {
41
39
  manifest.start_url = url_for('/index.html');
42
40
  }
43
-
44
41
  return {
45
42
  path: '/manifest.json',
46
43
  data: JSON.stringify(manifest)
@@ -1,11 +1,8 @@
1
1
  const {
2
2
  join
3
3
  } = require('path');
4
-
5
4
  const Hexo = require('hexo');
6
-
7
5
  const register = require('./manifest');
8
-
9
6
  const rootDir = join(__dirname, '../../../fixture/site');
10
7
  const hexo = new Hexo(rootDir, {
11
8
  silent: true
@@ -1,9 +1,6 @@
1
1
  const path = require('path');
2
-
3
2
  const Hexo = require('hexo');
4
-
5
3
  const register = require('./tags');
6
-
7
4
  const rootDir = path.join(__dirname, '../../../fixture/site');
8
5
  const hexo = new Hexo(rootDir, {
9
6
  silent: true
@@ -25,11 +25,11 @@ const PROVIDERS = {
25
25
  fontawesome: 'https://use.fontawesome.com/releases/v6.0.0/css/all.css'
26
26
  }
27
27
  };
28
+
28
29
  /**
29
30
  * Convert npm library path to CDN.js path
30
31
  * @private
31
32
  */
32
-
33
33
  const CDNJS_FIXTURES = {
34
34
  moment: (ver, fname) => ['moment.js', ver, fname.startsWith('min/') ? fname.substr(4) : fname],
35
35
  outdatedbrowser: (ver, fname) => ['outdated-browser', ver, fname.startsWith('outdatedbrowser/') ? fname.substr(16) : fname],
@@ -48,6 +48,7 @@ const UNPKG_FIXTURES = {
48
48
  mathjax: (ver, fname) => ['mathjax', ver, fname.indexOf('.min.') > -1 ? fname.replace(/\.min\./gi, '.') : fname],
49
49
  disqusjs: (ver, fname) => ['disqusjs', ver, fname.indexOf('.min.') > -1 ? fname.replace(/\.min\./gi, '.') : fname]
50
50
  };
51
+
51
52
  /**
52
53
  * Register the Hexo helper functions for resolving the URL of static files of JavaScript libraries,
53
54
  * web fonts, and FontAwesome icon fonts.
@@ -66,40 +67,31 @@ const UNPKG_FIXTURES = {
66
67
  * iconcdn();
67
68
  * // -> https://use.fontawesome.com/releases/v5.15.2/css/all.css
68
69
  */
69
-
70
70
  module.exports = function (hexo) {
71
71
  function applyFixture(fixture, _package, version, filename) {
72
72
  if (Object.prototype.hasOwnProperty.call(fixture, _package)) {
73
- const result = fixture[_package](version, filename); // package is not hosted on the given CDN
74
-
75
-
73
+ const result = fixture[_package](version, filename);
74
+ // package is not hosted on the given CDN
76
75
  if (!result.length) {
77
76
  throw new Error();
78
77
  }
79
-
80
78
  return result;
81
79
  }
82
-
83
80
  return [_package, version, filename];
84
81
  }
85
-
86
82
  hexo.extend.helper.register('cdn', function (_package, version, filename) {
87
83
  const {
88
84
  cdn = 'jsdelivr'
89
85
  } = typeof this.config.providers === 'object' ? this.config.providers : {};
90
86
  let _cdn = cdn;
91
-
92
87
  if (_cdn in PROVIDERS.LIBRARY) {
93
88
  _cdn = PROVIDERS.LIBRARY[_cdn];
94
- } // cdn.js does not follow a GitHub npm style like jsdeliver and unpkg do. Patch it!
95
-
96
-
89
+ }
90
+ // cdn.js does not follow a GitHub npm style like jsdeliver and unpkg do. Patch it!
97
91
  if (_cdn.startsWith('[cdnjs]')) {
98
92
  _cdn = _cdn.substr(7);
99
-
100
93
  try {
101
94
  [_package, version, filename] = applyFixture(CDNJS_FIXTURES, _package, version, filename);
102
-
103
95
  if (filename.startsWith('dist/')) {
104
96
  filename = filename.substr(5);
105
97
  }
@@ -113,29 +105,24 @@ module.exports = function (hexo) {
113
105
  _cdn = PROVIDERS.LIBRARY.jsdelivr;
114
106
  }
115
107
  }
116
-
117
108
  return _cdn.replace(/\${\s*package\s*}/gi, _package).replace(/\${\s*version\s*}/gi, version).replace(/\${\s*filename\s*}/gi, filename);
118
109
  });
119
110
  hexo.extend.helper.register('fontcdn', function (fontName, type = 'css') {
120
111
  let {
121
112
  fontcdn = 'google'
122
113
  } = typeof this.config.providers === 'object' ? this.config.providers : {};
123
-
124
114
  if (fontcdn in PROVIDERS.FONT) {
125
115
  fontcdn = PROVIDERS.FONT[fontcdn];
126
116
  }
127
-
128
117
  return fontcdn.replace(/\${\s*fontname\s*}/gi, fontName).replace(/\${\s*type\s*}/gi, type);
129
118
  });
130
119
  hexo.extend.helper.register('iconcdn', function () {
131
120
  let {
132
121
  iconcdn = 'fontawesome'
133
122
  } = typeof this.config.providers === 'object' ? this.config.providers : {};
134
-
135
123
  if (iconcdn in PROVIDERS.ICON) {
136
124
  iconcdn = PROVIDERS.ICON[iconcdn];
137
125
  }
138
-
139
126
  return iconcdn;
140
127
  });
141
128
  };
@@ -1,9 +1,6 @@
1
1
  const path = require('path');
2
-
3
2
  const Hexo = require('hexo');
4
-
5
3
  const register = require('./cdn');
6
-
7
4
  const rootDir = path.join(__dirname, '../../../fixture/site');
8
5
  const hexo = new Hexo(rootDir, {
9
6
  silent: true
@@ -1,9 +1,6 @@
1
1
  const path = require('path');
2
-
3
2
  const Hexo = require('hexo');
4
-
5
3
  const register = require('./page');
6
-
7
4
  const rootDir = path.join(__dirname, '../../../fixture/site');
8
5
  const hexo = new Hexo(rootDir, {
9
6
  silent: true
@@ -52,29 +52,23 @@ module.exports = function (hexo) {
52
52
  let title = '';
53
53
  let classes = '';
54
54
  let header = '';
55
-
56
55
  for (const option of options) {
57
56
  const [key, value] = option.split(':');
58
-
59
57
  switch (key) {
60
58
  case 'size':
61
59
  classes += ` is-${value}`;
62
60
  break;
63
-
64
61
  case 'color':
65
62
  classes += ` is-${value}`;
66
63
  break;
67
-
68
64
  case 'icon':
69
65
  icon = `<i class="${value} mr-2"></i>`;
70
66
  break;
71
-
72
67
  case 'title':
73
68
  title = value;
74
69
  break;
75
70
  }
76
71
  }
77
-
78
72
  if (icon !== '' || title !== '') {
79
73
  const inner = hexo.render.renderSync({
80
74
  text: icon + title,
@@ -82,7 +76,6 @@ module.exports = function (hexo) {
82
76
  });
83
77
  header = `<div class="message-header">${inner}</div>`;
84
78
  }
85
-
86
79
  return `<article class="message${classes}">
87
80
  ${header}
88
81
  <div class="message-body">
@@ -93,7 +86,6 @@ module.exports = function (hexo) {
93
86
  </div>
94
87
  </article>`;
95
88
  }
96
-
97
89
  hexo.extend.tag.register('message', processTag, {
98
90
  ends: true
99
91
  });
@@ -1,17 +1,12 @@
1
1
  const {
2
2
  join
3
3
  } = require('path');
4
-
5
4
  const Hexo = require('hexo');
6
-
7
5
  const cheerio = require('cheerio');
8
-
9
6
  const {
10
7
  minify
11
8
  } = require('html-minifier');
12
-
13
9
  const register = require('./message');
14
-
15
10
  const rootDir = join(__dirname, '../../../fixture/site');
16
11
  const hexo = new Hexo(rootDir, {
17
12
  silent: true
@@ -43,7 +38,6 @@ test('create default message', async () => {
43
38
  });
44
39
  test('create message with different colors', async () => {
45
40
  const render = hexo.extend.tag.render.bind(hexo.extend.tag);
46
-
47
41
  for (const color of ['dark', 'primary', 'link', 'info', 'success', 'warning', 'danger']) {
48
42
  const source = `{% message color:${color} %}content{% endmessage %}`;
49
43
  const actual = cheerio.load(await render(source), cheerioOptions, false).html();
@@ -52,7 +46,6 @@ test('create message with different colors', async () => {
52
46
  });
53
47
  test('create message with different sizes', async () => {
54
48
  const render = hexo.extend.tag.render.bind(hexo.extend.tag);
55
-
56
49
  for (const size of ['small', 'medium', 'large']) {
57
50
  const source = `{% message size:${size} %}content{% endmessage %}`;
58
51
  const actual = cheerio.load(await render(source), cheerioOptions, false).html();