starter主题logo修复

This commit is contained in:
tangly1024.com
2024-11-08 18:38:57 +08:00
parent ceaa9f9b57
commit c2d932402c
3 changed files with 13 additions and 8 deletions

View File

@@ -33,7 +33,7 @@ export const Header = props => {
return () => {
window.removeEventListener('scroll', navBarScollListener)
}
}, [[isDarkMode]])
}, [isDarkMode])
// 滚动监听
const throttleMs = 200
@@ -58,7 +58,7 @@ export const Header = props => {
<div className='container'>
<div className='relative -mx-4 flex items-center justify-between'>
{/* Logo */}
<Logo />
<Logo {...props} />
<div className='flex w-full items-center justify-between px-4'>
{/* 中间菜单 */}

View File

@@ -10,10 +10,12 @@ import { useEffect, useState } from 'react'
* 站点图标
* @returns
*/
export const Logo = ({ white }) => {
export const Logo = props => {
const { white, NOTION_CONFIG } = props
const router = useRouter()
const { isDarkMode } = useGlobal()
const logoWhite = siteConfig('STARTER_LOGO_WHITE')
const logoNormal = siteConfig('STARTER_LOGO')
const { isDarkMode } = useGlobal()
const [logo, setLogo] = useState(logoWhite)
const [logoTextColor, setLogoTextColor] = useState('text-white')
@@ -24,11 +26,12 @@ export const Logo = ({ white }) => {
const scrollY = window.scrollY
// 何时显示浅色或白底的logo
const homePageNavBar = router.route === '/' && scrollY < 10 // 在首页并且视窗在页面顶部
if (white || isDarkMode || homePageNavBar) {
setLogo(siteConfig('STARTER_LOGO_WHITE'))
setLogo(logoWhite)
setLogoTextColor('text-white')
} else {
setLogo(siteConfig('STARTER_LOGO'))
setLogo(logoNormal)
setLogoTextColor('text-black')
}
}, throttleMs)
@@ -50,8 +53,9 @@ export const Logo = ({ white }) => {
router.push('/')
}}
src={logo}
height={14}
alt='logo'
className='header-logo w-full'
className='header-logo w-full mr-1'
/>
)}
{/* logo文字 */}

View File

@@ -81,6 +81,7 @@ const LayoutBase = props => {
*/
const LayoutIndex = props => {
const count = siteConfig('STARTER_BLOG_COUNT', 3, CONFIG)
const { locale } = useGlobal()
const posts = props?.allNavPages ? props.allNavPages.slice(0, count) : []
return (
<>
@@ -108,7 +109,7 @@ const LayoutIndex = props => {
<Blog posts={posts} />
<div className='container mx-auto flex justify-end mb-4'>
<Link className='text-lg underline' href={'/archive'}>
<span>查看全部</span>
<span>{locale.COMMON.MORE}</span>
<i className='ml-2 fas fa-arrow-right' />
</Link>
</div>