hexo-component-inferno 0.14.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/schema.js +1 -1
- package/lib/hexo/filter/locals.js +1 -1
- package/lib/hexo/filter/locals.test.js +6 -6
- package/lib/hexo/helper/cdn.js +9 -8
- package/lib/hexo/helper/cdn.test.js +49 -7
- package/lib/hexo/tag/message.js +100 -0
- package/lib/hexo/tag/message.test.js +70 -0
- package/lib/hexo/tag/tabs.js +290 -0
- package/lib/hexo/tag/tabs.test.js +97 -0
- package/lib/schema/comment/disqusjs.json +4 -5
- package/lib/schema/comment/waline.json +28 -36
- package/lib/util/yaml.js +5 -10
- package/lib/view/comment/changyan.js +1 -1
- package/lib/view/comment/disqus.js +1 -1
- package/lib/view/comment/disqusjs.js +1 -1
- package/lib/view/comment/facebook.js +1 -1
- package/lib/view/comment/gitalk.js +1 -1
- package/lib/view/comment/gitment.js +1 -1
- package/lib/view/comment/isso.js +1 -1
- package/lib/view/comment/livere.js +1 -1
- package/lib/view/comment/utterances.js +1 -1
- package/lib/view/comment/valine.js +1 -1
- package/lib/view/comment/waline.js +30 -35
- package/lib/view/common/article_media.js +1 -1
- package/lib/view/donate/afdian.js +1 -1
- package/lib/view/donate/alipay.js +1 -1
- package/lib/view/donate/buymeacoffee.js +1 -1
- package/lib/view/donate/patreon.js +1 -1
- package/lib/view/donate/paypal.js +1 -1
- package/lib/view/donate/wechat.js +1 -1
- package/lib/view/misc/article_licensing.js +1 -1
- package/lib/view/misc/meta.js +1 -1
- package/lib/view/misc/open_graph.js +1 -1
- package/lib/view/misc/paginator.js +1 -1
- package/lib/view/misc/structured_data.js +1 -1
- package/lib/view/misc/web_app.js +1 -1
- package/lib/view/plugin/baidu_analytics.js +1 -1
- package/lib/view/plugin/bing_webmaster.js +1 -1
- package/lib/view/plugin/busuanzi.js +1 -1
- package/lib/view/plugin/cnzz.js +1 -1
- package/lib/view/plugin/cookie_consent.js +1 -1
- package/lib/view/plugin/gallery.js +1 -1
- package/lib/view/plugin/google_analytics.js +1 -1
- package/lib/view/plugin/hotjar.js +1 -1
- package/lib/view/plugin/katex.js +1 -1
- package/lib/view/plugin/mathjax.js +1 -1
- package/lib/view/plugin/outdated_browser.js +1 -1
- package/lib/view/plugin/progressbar.js +1 -1
- package/lib/view/plugin/statcounter.js +1 -1
- package/lib/view/plugin/twitter_conversion_tracking.js +1 -1
- package/lib/view/search/algolia.js +1 -1
- package/lib/view/search/baidu.js +1 -1
- package/lib/view/search/google_cse.js +1 -1
- package/lib/view/search/insight.js +1 -1
- package/lib/view/share/addthis.js +1 -1
- package/lib/view/share/addtoany.js +1 -1
- package/lib/view/share/bdshare.js +1 -1
- package/lib/view/share/sharejs.js +1 -1
- package/lib/view/share/sharethis.js +1 -1
- package/lib/view/widget/adsense.js +1 -1
- package/lib/view/widget/archives.js +1 -1
- package/lib/view/widget/categories.js +1 -1
- package/lib/view/widget/followit.js +1 -1
- package/lib/view/widget/links.js +1 -1
- package/lib/view/widget/recent_posts.js +1 -1
- package/lib/view/widget/subscribe_email.js +1 -1
- package/lib/view/widget/tags.js +1 -1
- package/lib/view/widget/toc.js +1 -1
- package/package.json +18 -13
package/lib/core/schema.js
CHANGED
|
@@ -49,7 +49,7 @@ module.exports = hexo => {
|
|
|
49
49
|
const configInThemeDir = path.join(hexo.theme_dir, '_config.' + layout + '.yml');
|
|
50
50
|
[configInSiteDir, configInThemeDir].forEach(configPath => {
|
|
51
51
|
if (fs.existsSync(configPath)) {
|
|
52
|
-
config = Object.assign(config, yaml.
|
|
52
|
+
config = Object.assign(config, yaml.load(fs.readFileSync(configPath)));
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
return config;
|
|
@@ -41,12 +41,12 @@ const basePageConfig = {
|
|
|
41
41
|
beforeAll(async () => {
|
|
42
42
|
await hexo.init();
|
|
43
43
|
await hexo.load();
|
|
44
|
-
siteConfig = yaml.
|
|
45
|
-
themeConfig = yaml.
|
|
46
|
-
pageConfigInSiteDir = yaml.
|
|
47
|
-
postConfigInSiteDir = yaml.
|
|
48
|
-
pageConfigInThemeDir = yaml.
|
|
49
|
-
postConfigInThemeDir = yaml.
|
|
44
|
+
siteConfig = yaml.load(fs.readFileSync(path.join(hexo.base_dir, '_config.yml')));
|
|
45
|
+
themeConfig = yaml.load(fs.readFileSync(path.join(hexo.theme_dir, '_config.yml')));
|
|
46
|
+
pageConfigInSiteDir = yaml.load(fs.readFileSync(path.join(hexo.base_dir, '_config.page.yml')));
|
|
47
|
+
postConfigInSiteDir = yaml.load(fs.readFileSync(path.join(hexo.base_dir, '_config.post.yml')));
|
|
48
|
+
pageConfigInThemeDir = yaml.load(fs.readFileSync(path.join(hexo.theme_dir, '_config.page.yml')));
|
|
49
|
+
postConfigInThemeDir = yaml.load(fs.readFileSync(path.join(hexo.theme_dir, '_config.post.yml')));
|
|
50
50
|
register(hexo);
|
|
51
51
|
});
|
|
52
52
|
test('Register all helper functions to "locals.helper"', async () => {
|
package/lib/hexo/helper/cdn.js
CHANGED
|
@@ -13,16 +13,20 @@ const PROVIDERS = {
|
|
|
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
15
|
unpkg: 'https://unpkg.com/${ package }@${ version }/${ filename }',
|
|
16
|
-
bootcdn: '[cdnjs]https://cdn.bootcdn.net/ajax/libs/${ 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 }'
|
|
17
18
|
},
|
|
18
19
|
FONT: {
|
|
19
20
|
google: 'https://fonts.googleapis.com/${ type }?family=${ fontname }',
|
|
20
|
-
loli: 'https://fonts.loli.net/${ type }?family=${ fontname }'
|
|
21
|
+
loli: 'https://fonts.loli.net/${ type }?family=${ fontname }',
|
|
22
|
+
fontim: 'https://fonts.font.im/${ type }?family=${ fontname }',
|
|
23
|
+
ustc: 'https://fonts.lug.ustc.edu.cn/${ type }?family=${ fontname }'
|
|
21
24
|
},
|
|
22
25
|
ICON: {
|
|
23
26
|
loli: 'https://cdnjs.loli.net/ajax/libs/font-awesome/5.15.2/css/all.min.css',
|
|
24
27
|
fontawesome: 'https://use.fontawesome.com/releases/v5.15.2/css/all.css',
|
|
25
|
-
bootcdn: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.3/css/all.min.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'
|
|
26
30
|
}
|
|
27
31
|
};
|
|
28
32
|
/**
|
|
@@ -44,8 +48,7 @@ const CDNJS_FIXTURES = {
|
|
|
44
48
|
// disqusjs is not hosted on CDN.js
|
|
45
49
|
disqusjs: (ver, fname) => [],
|
|
46
50
|
cookieconsent: (ver, fname) => ['cookieconsent', ver, fname.startsWith('build/') ? fname.substr(6) : fname],
|
|
47
|
-
|
|
48
|
-
'@waline/client': (ver, fname) => []
|
|
51
|
+
'@waline/client': (ver, fname) => ['waline', ver, fname]
|
|
49
52
|
};
|
|
50
53
|
const UNPKG_FIXTURES = {
|
|
51
54
|
mathjax: (ver, fname) => ['mathjax', ver, fname.indexOf('.min.') > -1 ? fname.replace(/\.min\./gi, '.') : fname],
|
|
@@ -98,9 +101,7 @@ module.exports = function (hexo) {
|
|
|
98
101
|
|
|
99
102
|
|
|
100
103
|
if (_cdn.startsWith('[cdnjs]')) {
|
|
101
|
-
|
|
102
|
-
_cdn = _cdn.substr(7);
|
|
103
|
-
}
|
|
104
|
+
_cdn = _cdn.substr(7);
|
|
104
105
|
|
|
105
106
|
try {
|
|
106
107
|
[_package, version, filename] = applyFixture(CDNJS_FIXTURES, _package, version, filename);
|
|
@@ -17,45 +17,59 @@ 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.
|
|
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.5.4', 'dist/Waline.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.
|
|
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.5.4/dist/Waline.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.
|
|
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.5.4/dist/Waline.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://
|
|
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://cdnjs.cloudflare.com/ajax/libs/waline/1.5.4/Waline.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://
|
|
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://cdnjs.loli.net/ajax/libs/waline/1.5.4/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.bootcdn.net/ajax/libs/waline/1.5.4/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://lib.baomitu.com/waline/1.5.4/Waline.min.js', 'https://lib.baomitu.com/example/1.0.0/example.js'];
|
|
45
59
|
cases.forEach((func, i) => expect(func()).toBe(expected[i]));
|
|
46
60
|
});
|
|
47
61
|
test('Custom CDN', () => {
|
|
48
62
|
hexo.config.providers = {
|
|
49
63
|
cdn: 'https://my.cdn/${ package }@${ version }/${ filename }'
|
|
50
64
|
};
|
|
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.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.
|
|
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.5.4/dist/Waline.min.js', 'https://my.cdn/example@1.0.0/example.js'];
|
|
52
66
|
cases.forEach((func, i) => expect(func()).toBe(expected[i]));
|
|
53
67
|
});
|
|
54
68
|
test('Custom CDN.js-style CDN', () => {
|
|
55
69
|
hexo.config.providers = {
|
|
56
70
|
cdn: '[cdnjs]https://my.cdn/ajax/libs/${ package }/${ version }/${ filename }'
|
|
57
71
|
};
|
|
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://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
|
|
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://my.cdn/ajax/libs/waline/1.5.4/Waline.min.js', 'https://my.cdn/ajax/libs/example/1.0.0/example.js'];
|
|
59
73
|
cases.forEach((func, i) => expect(func()).toBe(expected[i]));
|
|
60
74
|
});
|
|
61
75
|
});
|
|
@@ -79,6 +93,20 @@ describe('Get web font URL', () => {
|
|
|
79
93
|
const expected = ['https://fonts.loli.net/css?family=Ubuntu:400,600|Source+Code+Pro', 'https://fonts.loli.net/css2?family=Roboto:wght@100;400&display=swap'];
|
|
80
94
|
cases.forEach((func, i) => expect(func()).toBe(expected[i]));
|
|
81
95
|
});
|
|
96
|
+
test('fontim', () => {
|
|
97
|
+
hexo.config.providers = {
|
|
98
|
+
fontcdn: 'fontim'
|
|
99
|
+
};
|
|
100
|
+
const expected = ['https://fonts.font.im/css?family=Ubuntu:400,600|Source+Code+Pro', 'https://fonts.font.im/css2?family=Roboto:wght@100;400&display=swap'];
|
|
101
|
+
cases.forEach((func, i) => expect(func()).toBe(expected[i]));
|
|
102
|
+
});
|
|
103
|
+
test('ustc', () => {
|
|
104
|
+
hexo.config.providers = {
|
|
105
|
+
fontcdn: 'ustc'
|
|
106
|
+
};
|
|
107
|
+
const expected = ['https://fonts.lug.ustc.edu.cn/css?family=Ubuntu:400,600|Source+Code+Pro', 'https://fonts.lug.ustc.edu.cn/css2?family=Roboto:wght@100;400&display=swap'];
|
|
108
|
+
cases.forEach((func, i) => expect(func()).toBe(expected[i]));
|
|
109
|
+
});
|
|
82
110
|
test('Custom web font CDN', () => {
|
|
83
111
|
hexo.config.providers = {
|
|
84
112
|
fontcdn: 'https://my.cdn/${ type }?family=${ fontname }'
|
|
@@ -107,6 +135,20 @@ describe('Get icon font URL', () => {
|
|
|
107
135
|
const expected = ['https://cdnjs.loli.net/ajax/libs/font-awesome/5.15.2/css/all.min.css'];
|
|
108
136
|
cases.forEach((func, i) => expect(func()).toBe(expected[i]));
|
|
109
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'];
|
|
150
|
+
cases.forEach((func, i) => expect(func()).toBe(expected[i]));
|
|
151
|
+
});
|
|
110
152
|
test('Custom web font CDN', () => {
|
|
111
153
|
hexo.config.providers = {
|
|
112
154
|
iconcdn: 'https://my.cdn/icon'
|
|
@@ -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,70 @@
|
|
|
1
|
+
const {
|
|
2
|
+
join
|
|
3
|
+
} = require('path');
|
|
4
|
+
|
|
5
|
+
const Hexo = require('hexo');
|
|
6
|
+
|
|
7
|
+
const cheerio = require('cheerio');
|
|
8
|
+
|
|
9
|
+
const register = require('./message');
|
|
10
|
+
|
|
11
|
+
const rootDir = join(__dirname, '../../../fixture/site');
|
|
12
|
+
const hexo = new Hexo(rootDir, {
|
|
13
|
+
silent: true
|
|
14
|
+
});
|
|
15
|
+
const cheerioOptions = {
|
|
16
|
+
xml: {
|
|
17
|
+
normalizeWhitespace: true
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
beforeAll(async () => {
|
|
21
|
+
await hexo.init();
|
|
22
|
+
await hexo.load();
|
|
23
|
+
register(hexo);
|
|
24
|
+
await hexo.loadPlugin(require.resolve('hexo-renderer-markdown'));
|
|
25
|
+
});
|
|
26
|
+
test('create default message', async () => {
|
|
27
|
+
const render = hexo.extend.tag.render.bind(hexo.extend.tag);
|
|
28
|
+
let source = '{% message %}**content**{% endmessage %}';
|
|
29
|
+
let actual = cheerio.load(await render(source), cheerioOptions, false).html();
|
|
30
|
+
expect(actual).toEqual('<article class="message"> <div class="message-body"> ' + '<p><strong>content</strong></p> </div> </article>');
|
|
31
|
+
source = '{% message %}\n# title\n{% endmessage %}';
|
|
32
|
+
actual = cheerio.load(await render(source), cheerioOptions, false).html();
|
|
33
|
+
expect(actual).toEqual('<article class="message"> <div class="message-body"> ' + '<h1 id="title"><a class="header-anchor" href="#title">¶</a> title</h1> ' + '</div> </article>');
|
|
34
|
+
});
|
|
35
|
+
test('create message with different colors', async () => {
|
|
36
|
+
const render = hexo.extend.tag.render.bind(hexo.extend.tag);
|
|
37
|
+
|
|
38
|
+
for (const color of ['dark', 'primary', 'link', 'info', 'success', 'warning', 'danger']) {
|
|
39
|
+
const source = `{% message color:${color} %}content{% endmessage %}`;
|
|
40
|
+
const actual = cheerio.load(await render(source), cheerioOptions, false).html();
|
|
41
|
+
expect(actual).toEqual(`<article class="message is-${color}"> <div class="message-body"> <p>content</p> ` + '</div> </article>');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
test('create message with different sizes', async () => {
|
|
45
|
+
const render = hexo.extend.tag.render.bind(hexo.extend.tag);
|
|
46
|
+
|
|
47
|
+
for (const size of ['small', 'medium', 'large']) {
|
|
48
|
+
const source = `{% message size:${size} %}content{% endmessage %}`;
|
|
49
|
+
const actual = cheerio.load(await render(source), cheerioOptions, false).html();
|
|
50
|
+
expect(actual).toEqual(`<article class="message is-${size}"> <div class="message-body"> <p>content</p> ` + '</div> </article>');
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
test('create message with an icon', async () => {
|
|
54
|
+
const render = hexo.extend.tag.render.bind(hexo.extend.tag);
|
|
55
|
+
const source = '{% message "icon:fas fas-file" %}content{% endmessage %}';
|
|
56
|
+
const actual = cheerio.load(await render(source), cheerioOptions, false).html();
|
|
57
|
+
expect(actual).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>');
|
|
58
|
+
});
|
|
59
|
+
test('create message with a title', async () => {
|
|
60
|
+
const render = hexo.extend.tag.render.bind(hexo.extend.tag);
|
|
61
|
+
const source = '{% message "title:*message title*" %}content{% endmessage %}';
|
|
62
|
+
const actual = cheerio.load(await render(source), cheerioOptions, false).html();
|
|
63
|
+
expect(actual).toEqual('<article class="message"> <div class="message-header"><p>' + '<em>message title</em></p> </div> <div class="message-body"> <p>content</p> ' + '</div> </article>');
|
|
64
|
+
});
|
|
65
|
+
test('create message with all properties', async () => {
|
|
66
|
+
const render = hexo.extend.tag.render.bind(hexo.extend.tag);
|
|
67
|
+
const source = '{% message color:success size:small "icon:fas fas-file" ' + '"title:*message title*" %}content{% endmessage %}';
|
|
68
|
+
const actual = cheerio.load(await render(source), cheerioOptions, false).html();
|
|
69
|
+
expect(actual).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>');
|
|
70
|
+
});
|