Hexo8.x主题添加可切换的黑暗模式
切换黑暗或白天模式
效果如下:
在博客目录下安装
hexo-next-darkmode
插件1
npm install hexo-next-darkmode --save
配置
hexo
插件在Next主题的
_config.yml
文件最后面添加1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18# Darkmode JS
# For more information: https://github.com/rqh656418510/hexo-next-darkmode, https://github.com/sandoche/Darkmode.js
darkmode_js:
enable: true
bottom: '64px' # default: '32px'
right: 'unset' # default: '32px'
left: '32px' # default: 'unset'
time: '0.5s' # default: '0.3s'
mixColor: 'transparent' # default: '#fff'
backgroundColor: 'transparent' # default: '#fff'
buttonColorDark: '#100f2c' # default: '#100f2c'
buttonColorLight: '#fff' # default: '#fff'
isActivated: true # default false
saveInCookies: false # default: true
label: '🌓' # default: ''
autoMatchOsTheme: false # default: true
libUrl: # Set custom library cdn url for Darkmode.js同时需要把
_config.yml
中的pjax
打开,并且关闭原生的暗黑模式1
2
3pjax: true
darkmode: false最后重新构建生成静态文件即可
1
2
3hexo clean
hexo g
hexo d