hexo 深色模式调整

This commit is contained in:
tangly1024
2022-03-28 15:32:57 +08:00
parent a7fe31da71
commit bca48b01ec
8 changed files with 21 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import { useEffect } from 'react'
export default function HeaderArticle ({ post }) {
const headerImage = post?.page_cover ? `url("${post.page_cover}")` : `url("/${CONFIG_HEXO.HOME_BANNER_IMAGE}")`
const { isDarkMode } = useGlobal()
const { locale } = useGlobal()
const date = formatDate(
@@ -24,6 +25,7 @@ export default function HeaderArticle ({ post }) {
nav && nav.classList.replace('bg-none', 'bg-white')
nav && nav.classList.replace('text-white', 'text-black')
}
updateTopNav()
}
useEffect(() => {
scrollTrigger()
@@ -33,6 +35,17 @@ export default function HeaderArticle ({ post }) {
}
})
const updateTopNav = () => {
if (!isDarkMode) {
const stickyNavElement = document.getElementById('sticky-nav')
if (window.scrollY < window.innerHeight) {
stickyNavElement?.classList?.add('dark')
} else {
stickyNavElement?.classList?.remove('dark')
}
}
}
return (
<div
id="header"