forked from next-theme/hexo-next-valine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
37 lines (27 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* global hexo */
'use strict';
const Util = require('@next-theme/utils');
const utils = new Util(hexo, __dirname);
// Add comment
hexo.extend.filter.register('theme_inject', injects => {
const config = utils.defaultConfigFile('twikoo', 'default.yaml');
if (!config.enable || !config.envId) return;
injects.comment.raw('twikoo', '<div class="comments"><div id="twikoo-comments"></div></div>', {}, { cache: true });
injects.bodyEnd.raw('twikoo', utils.getFileContent('twikoo.njk'));
});
// Add post_meta
hexo.extend.filter.register('theme_inject', injects => {
const config = utils.defaultConfigFile('twikoo', 'default.yaml');
if (!config.enable || !config.envId) return;
if (config.visitor) {
injects.postMeta.raw('twikoo', `
<span id="{{ url_for(post.path) }}" class="post-meta-item twikoo_visitors" data-flag-title="{{ post.title }}" title="{{ __('post.views') }}">
<span class="post-meta-item-icon">
<i class="far fa-eye"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span id="twikoo_visitors"></span>
</span>
`, {}, {});
}
});