Skip to content

Commit

Permalink
HEXO 7.0 对配置文件的改动
Browse files Browse the repository at this point in the history
  • Loading branch information
f-dong committed Aug 26, 2024
1 parent fe70b2b commit 1438c1b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/events/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@ function merge(target, source) {
hexo.on('generateBefore', () => {
merge(hexo.theme.config, hexo.config.theme_config);

hexo.theme.config.highlight = hexo.config.highlight.enable ? {enable: true} : {enable: false};
hexo.theme.config.prismjs = hexo.config.prismjs.enable ? {enable: true} : {enable: false};
// hexo v7.0.0 新的配置改动
if (hexo.config.syntax_highlighter) {
if (hexo.config.syntax_highlighter === 'prismjs') {
hexo.theme.config.prismjs = {enable: true};
hexo.theme.config.highlight = {enable: false};
} else if (hexo.config.syntax_highlighter === 'highlight.js') {
hexo.theme.config.prismjs = {enable: false};
hexo.theme.config.highlight = {enable: true};
} else {
hexo.log.warn('Unsupported syntax highlighter: ' + hexo.config.syntax_highlighter);
}
} else { // v7.0.0 以下版本
hexo.theme.config.highlight = hexo.config.highlight.enable ? {enable: true} : {enable: false};
hexo.theme.config.prismjs = hexo.config.prismjs.enable ? {enable: true} : {enable: false};
}

// 评论系统,旧配置兼容
if (typeof hexo.theme.config.comment !== 'object' && hexo.theme.config.gitalk) {
Expand Down

0 comments on commit 1438c1b

Please sign in to comment.