Skip to content

Commit

Permalink
代码主题切换
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Jul 26, 2023
1 parent c3ccb7f commit 947fd1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion blog.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const BLOG = {
PRISM_JS_PATH: 'https://npm.elemecdn.com/prismjs@1.29.0/components/',
// 代码主题 https://github.com/PrismJS/prism-themes
PRISM_THEME_PREFIX_PATH: 'https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-okaidia.css', // 代码块默认主题
PRISM_THEME_SWITCH: true, // 是否开启浅色/深色模式代码主题切换
PRISM_THEME_SWITCH: process.env.NEXT_PUBLIC_PRISM_THEME_SWITCH || true, // 是否开启浅色/深色模式代码主题切换
PRISM_THEME_LIGHT_PATH: 'https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-solarizedlight.css', // 浅色模式主题
PRISM_THEME_DARK_PATH: 'https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-okaidia.min.css', // 深色模式主题

Expand Down
2 changes: 1 addition & 1 deletion components/PrismMac.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const loadPrismThemeCSS = () => {
let PRISM_THEME
let PRISM_PREVIOUS
const themeClass = document.documentElement.className
if (BLOG.PRISM_THEME_SWITCH) {
if (JSON.parse(BLOG.PRISM_THEME_SWITCH)) {
if (themeClass === 'dark') {
PRISM_THEME = BLOG.PRISM_THEME_DARK_PATH
PRISM_PREVIOUS = BLOG.PRISM_THEME_LIGHT_PATH
Expand Down

0 comments on commit 947fd1d

Please sign in to comment.