Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryc127 committed Apr 10, 2023
2 parents 04e36c8 + 5c2894d commit 8d5ca45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ darkmode:
# autoChangeMode: 2 Switch dark mode between 6 pm to 6 am
# autoChangeMode: false
autoChangeMode: false
# Set the light mode time. The value is between 0 and 24. If not set, the default value is 6 and 18
start: # 8
end: # 22

# show scroll percent in scroll-to-top button
rightside_scroll_percent: false
Expand Down
7 changes: 4 additions & 3 deletions scripts/helpers/inject_head_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

hexo.extend.helper.register('inject_head_js', function () {
const { darkmode, aside } = this.theme

const start = darkmode.start ? darkmode.start : 6
const end = darkmode.end ? darkmode.end : 18
const { theme_color } = hexo.theme.config
const themeColorLight = (theme_color && theme_color.enable && theme_color.meta_theme_color_light) || '#ffffff'
const themeColorDark = (theme_color && theme_color.enable && theme_color.meta_theme_color_dark) || '#0d0d0d'
Expand Down Expand Up @@ -110,7 +111,7 @@ hexo.extend.helper.register('inject_head_js', function () {
else if (isNotSpecified || hasNoSupport) {
const now = new Date()
const hour = now.getHours()
const isNight = hour <= 6 || hour >= 18
const isNight = hour <= ${start} || hour >= ${end}
isNight ? activateDarkMode() : activateLightMode()
}
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
Expand All @@ -125,7 +126,7 @@ hexo.extend.helper.register('inject_head_js', function () {
darkmodeJs += `
const now = new Date()
const hour = now.getHours()
const isNight = hour <= 6 || hour >= 18
const isNight = hour <= ${start} || hour >= ${end}
if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
else if (t === 'light') activateLightMode()
else activateDarkMode()
Expand Down

0 comments on commit 8d5ca45

Please sign in to comment.