diff --git a/layout/_macro/post.njk b/layout/_macro/post.njk index dd32126..f980228 100644 --- a/layout/_macro/post.njk +++ b/layout/_macro/post.njk @@ -97,7 +97,7 @@ {%- endif %} {# LeanCloud PageView #} - {%- if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appId and theme.valine.appKey and theme.valine.visitor) %} + {%- if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.visitor) %} diff --git a/layout/_third-party/statistics/lean-analytics.njk b/layout/_third-party/statistics/lean-analytics.njk index baf13d1..2b82251 100644 --- a/layout/_third-party/statistics/lean-analytics.njk +++ b/layout/_third-party/statistics/lean-analytics.njk @@ -1,4 +1,4 @@ -{%- if theme.leancloud_visitors.enable and not theme.valine.visitor %} +{%- if theme.leancloud_visitors.enable %} (function() { function leancloudSelector(url) { diff --git a/scripts/events/lib/config.js b/scripts/events/lib/config.js index 1b32993..a85ff3a 100644 --- a/scripts/events/lib/config.js +++ b/scripts/events/lib/config.js @@ -14,15 +14,23 @@ module.exports = hexo => { hexo.theme.config = merge(hexo.theme.config, hexo.config.theme_config); } - const { cache, language_switcher } = hexo.theme.config; + const { cache, language_switcher, leancloud_visitors, valine } = hexo.theme.config; + const warning = function(...args) { + hexo.log.warn(`Since ${args[0]} is turned on, the ${args[1]} is disabled to avoid potential hazards.`); + }; + if (cache && cache.enable && language_switcher) { - hexo.log.warn('Since language_switcher is turned on, the caching is disabled to avoid potential hazards.'); + warning('language_switcher', 'caching'); cache.enable = false; } if (cache && cache.enable && hexo.config.relative_link) { - hexo.log.warn('Since caching is turned on, the `relative_link` option in Hexo `_config.yml` is set to `false` to avoid potential hazards.'); + warning('caching', '`relative_link` option in Hexo `_config.yml`'); 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; // Custom languages support. Introduced in NexT v6.3.0. diff --git a/scripts/filters/locals.js b/scripts/filters/locals.js index e6d95b7..67bd121 100644 --- a/scripts/filters/locals.js +++ b/scripts/filters/locals.js @@ -5,11 +5,11 @@ const keys = ['toc', 'reward_settings', 'quicklink']; hexo.extend.filter.register('template_locals', locals => { - const { env, config } = hexo; + const { version, config } = hexo; const { __, theme, page } = locals; const { i18n } = hexo.theme; // Hexo & NexT version - locals.hexo_version = env.version; + locals.hexo_version = version; locals.next_version = require('../../package.json').version; // Language & Config locals.title = __('title') !== 'title' ? __('title') : config.title;