Remove Valine

This commit is contained in:
Mimi 2020-11-28 15:30:05 +08:00
parent 7bf3e602a1
commit 6c94cfb45f
5 changed files with 2 additions and 57 deletions

View File

@ -88,10 +88,6 @@ disqusjs_css:
name: disqusjs name: disqusjs
version: 1.3.0 version: 1.3.0
file: dist/disqusjs.css file: dist/disqusjs.css
valine:
name: valine
version: 1.4.14
file: dist/Valine.min.js
gitalk_js: gitalk_js:
name: gitalk name: gitalk
version: 1.7.0 version: 1.7.0

View File

@ -51,7 +51,7 @@
{%- endif %} {%- endif %}
{# LeanCloud PageView #} {# LeanCloud PageView #}
{%- if theme.leancloud_visitors.enable or (theme.valine and theme.valine.enable and theme.valine.visitor) %} {%- if theme.leancloud_visitors.enable %}
<span id="{{ url_for(post.path) }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ post.title }}" title="{{ __('post.views') }}"> <span id="{{ url_for(post.path) }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ post.title }}" title="{{ __('post.views') }}">
<span class="post-meta-item-icon"> <span class="post-meta-item-icon">
<i class="far fa-eye"></i> <i class="far fa-eye"></i>

View File

@ -1,12 +0,0 @@
{%- set serverURLs = theme.valine.serverURLs or 'https://' + theme.valine.appId.slice(0, 8) | lower + '.api.lncldglobal.com' %}
<script>
NexT.utils.loadComments('#valine-comments', () => {
NexT.utils.getScript('{{ theme.vendors.valine }}', () => {
new Valine(Object.assign({{ theme.valine | safedump }}, {
el: '#valine-comments',
path: {{ url_for(page.path) | replace(r/index\.html$/, '') | safedump }},
serverURLs: {{ serverURLs | safedump }}
}));
}, window.Valine);
});
</script>

View File

@ -10,7 +10,7 @@ module.exports = hexo => {
hexo.log.warn('Documentation: https://theme-next.js.org/docs/getting-started/configuration.html'); hexo.log.warn('Documentation: https://theme-next.js.org/docs/getting-started/configuration.html');
} }
const { cache, language_switcher, leancloud_visitors, valine } = hexo.theme.config; const { cache, language_switcher } = hexo.theme.config;
const warning = function(...args) { const warning = function(...args) {
hexo.log.warn(`Since ${args[0]} is turned on, the ${args[1]} is disabled to avoid potential hazards.`); hexo.log.warn(`Since ${args[0]} is turned on, the ${args[1]} is disabled to avoid potential hazards.`);
}; };
@ -23,10 +23,6 @@ module.exports = hexo => {
warning('caching', '`relative_link` option in Hexo `_config.yml`'); warning('caching', '`relative_link` option in Hexo `_config.yml`');
hexo.config.relative_link = false; hexo.config.relative_link = false;
} }
if (leancloud_visitors && leancloud_visitors.enable && valine && valine.enable && valine.visitor) {
warning('valine.visitor', 'leancloud_visitors');
leancloud_visitors.enable = false;
}
hexo.config.meta_generator = false; hexo.config.meta_generator = false;
// Custom languages support. Introduced in NexT v6.3.0. // Custom languages support. Introduced in NexT v6.3.0.

View File

@ -1,35 +0,0 @@
/* global hexo */
'use strict';
const path = require('path');
const { iconText } = require('./common');
// Add comment
hexo.extend.filter.register('theme_inject', injects => {
const theme = hexo.theme.config;
if (!theme.valine || !theme.valine.enable || !theme.valine.appId || !theme.valine.appKey) return;
injects.comment.raw('valine', '<div class="comments" id="valine-comments"></div>', {}, {cache: true});
injects.bodyEnd.file('valine', path.join(hexo.theme_dir, 'layout/_third-party/comments/valine.njk'));
});
// Add post_meta
hexo.extend.filter.register('theme_inject', injects => {
const theme = hexo.theme.config;
if (!theme.valine || !theme.valine.enable || !theme.valine.appId || !theme.valine.appKey) return;
injects.postMeta.raw('valine', `
{% if post.comments and (is_post() or theme.valine.comment_count) %}
<span class="post-meta-item">
${iconText('far fa-comment', 'valine')}
<a title="valine" href="{{ url_for(post.path) }}#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="{{ url_for(post.path) }}" itemprop="commentCount"></span>
</a>
</span>
{% endif %}
`, {}, {});
});