From 269eae34c415bc253cefb2cb7b409127a7de944e Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Sun, 17 Dec 2023 13:00:18 +0800 Subject: [PATCH] Adapt to Hexo 7 highlight settings --- scripts/events/lib/highlight.js | 4 ++-- scripts/helpers/next-config.js | 2 +- scripts/helpers/next-vendors.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/events/lib/highlight.js b/scripts/events/lib/highlight.js index 03564a0..b3b8d00 100644 --- a/scripts/events/lib/highlight.js +++ b/scripts/events/lib/highlight.js @@ -15,12 +15,12 @@ module.exports = hexo => { config.highlight.hljs = false; config.prismjs = config.prismjs || {}; theme.highlight = { - enable: config.highlight.enable && !config.prismjs.enable, + enable: config.syntax_highlighter === 'highlight.js' || config.highlight.enable, light : highlightTheme(theme.codeblock.theme.light), dark : highlightTheme(theme.codeblock.theme.dark) }; theme.prism = { - enable: config.prismjs.enable, + enable: config.syntax_highlighter === 'prismjs' || config.prismjs.enable, light : prismTheme(theme.codeblock.prism.light), dark : prismTheme(theme.codeblock.prism.dark), number: resolve('prismjs', 'plugins/line-numbers/prism-line-numbers.css') diff --git a/scripts/helpers/next-config.js b/scripts/helpers/next-config.js index 824644f..5c93fb8 100644 --- a/scripts/helpers/next-config.js +++ b/scripts/helpers/next-config.js @@ -27,7 +27,7 @@ hexo.extend.helper.register('next_config', function() { comments : theme.comments, stickytabs: theme.tabs.sticky, motion : theme.motion, - prism : config.prismjs.enable && !config.prismjs.preprocess, + prism : theme.prism.enable && !config.prismjs.preprocess, i18n : { placeholder: __('search.placeholder'), empty : __('search.empty', '${query}'), diff --git a/scripts/helpers/next-vendors.js b/scripts/helpers/next-vendors.js index 80d44f0..0c06549 100644 --- a/scripts/helpers/next-vendors.js +++ b/scripts/helpers/next-vendors.js @@ -5,7 +5,7 @@ hexo.extend.helper.register('js_vendors', function() { const { config, theme } = this; const vendors = ['anime']; - if (config.prismjs.enable && !config.prismjs.preprocess) { + if (theme.prism.enable && !config.prismjs.preprocess) { vendors.push('prism', 'prism_autoloader'); if (config.prismjs.line_number) { vendors.push('prism_line_numbers');