Fix changyan undefined

This commit is contained in:
Mimi 2025-09-04 00:15:45 +08:00
parent 9519ed1733
commit b27b8ebe44
2 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ const { iconText } = require('./common');
// Add comment
hexo.extend.filter.register('theme_inject', injects => {
const config = hexo.theme.config.changyan;
if (!config.enable || !config.appid || !config.appkey) return;
if (!config || !config.enable || !config.appid || !config.appkey) return;
injects.comment.raw('changyan', '<div class="comments" id="SOHUCS" sid="{{ gitalk_md5(page.path) }}"></div>', {}, {});
@ -19,7 +19,7 @@ hexo.extend.filter.register('theme_inject', injects => {
// Add post_meta
hexo.extend.filter.register('theme_inject', injects => {
const config = hexo.theme.config.changyan;
if (!config.enable || !config.count || !config.appid || !config.appkey) return;
if (!config || !config.enable || !config.count || !config.appid || !config.appkey) return;
injects.postMeta.raw('changyan', `
{% if post.comments %}

View File

@ -68,7 +68,7 @@ hexo.extend.filter.register('after_generate', () => {
}
// Comments
if (!theme.changyan.enable || !theme.changyan.appid || !theme.changyan.appkey) {
if (!theme.changyan || !theme.changyan.enable || !theme.changyan.appid || !theme.changyan.appkey) {
hexo.route.remove('js/third-party/comments/changyan.js');
}