Skip to content

Commit

Permalink
Magzine主题调整
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Nov 21, 2024
1 parent f1e3d77 commit fb96bc7
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 221 deletions.
2 changes: 1 addition & 1 deletion themes/magzine/components/ArticleInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TagItemMini from './TagItemMini'
* @returns
*/
export default function ArticleInfo(props) {
const { post, siteInfo } = props
const { post } = props

return (
<>
Expand Down
3 changes: 2 additions & 1 deletion themes/magzine/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import PoweredBy from '@/components/PoweredBy'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import CONFIG from '../config'
import SocialButton from './SocialButton'

/**
* 网页底脚
*/
const Footer = ({ title }) => {
const { siteInfo } = useGlobal()
const MAGZINE_FOOTER_LINKS = siteConfig('MAGZINE_FOOTER_LINKS', [])
const MAGZINE_FOOTER_LINKS = siteConfig('MAGZINE_FOOTER_LINKS', [], CONFIG)

return (
<footer
Expand Down
8 changes: 4 additions & 4 deletions themes/magzine/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { MenuItemDrop } from './MenuItemDrop'
*/
export default function Header(props) {
const { customNav, customMenu } = props
const [isOpen, changeShow] = useState(false)
const [isOpen, setOpen] = useState(false)
const collapseRef = useRef(null)
const lastScrollY = useRef(0) // 用于存储上一次的滚动位置
const { locale } = useGlobal()
Expand Down Expand Up @@ -57,13 +57,13 @@ export default function Header(props) {
let links = defaultLinks.concat(customNav)

const toggleMenuOpen = () => {
changeShow(!isOpen)
setOpen(!isOpen)
}

// 向下滚动时,调整导航条高度
useEffect(() => {
scrollTrigger()
changeShow(false)
setOpen(false)
window.addEventListener('scroll', scrollTrigger)
return () => {
window.removeEventListener('scroll', scrollTrigger)
Expand Down Expand Up @@ -216,7 +216,7 @@ export default function Header(props) {
collapseRef={collapseRef}
isOpen={isOpen}
className='md:hidden'>
<div className='bg-white dark:bg-hexo-black-gray pt-1 py-2 lg:hidden '>
<div className='bg-white dark:bg-hexo-black-gray pt-1 py-2'>
<MenuBarMobile
{...props}
onHeightChange={param =>
Expand Down
10 changes: 5 additions & 5 deletions themes/magzine/components/MenuItemCollapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { useEffect, useState } from 'react'
*/
export const MenuItemCollapse = props => {
const { link } = props
const [show, changeShow] = useState(false)
const [show, setShow] = useState(false)
const hasSubMenu = link?.subMenus?.length > 0

const [isOpen, changeIsOpen] = useState(false)
const [isOpen, setOpen] = useState(false)

const router = useRouter()

Expand All @@ -24,16 +24,16 @@ export const MenuItemCollapse = props => {
const selected = router.pathname === link.href || router.asPath === link.href

const toggleShow = () => {
changeShow(!show)
setShow(!show)
}

const toggleOpenSubMenu = () => {
changeIsOpen(!isOpen)
setOpen(!isOpen)
}

// 路由切换时菜单收起
useEffect(() => {
changeIsOpen(false)
setOpen(false)
}, [router])

return (
Expand Down
40 changes: 21 additions & 19 deletions themes/magzine/components/PostItemCardTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import NotionPage from '@/components/NotionPage'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import CONFIG from '../config'
import CategoryItem from './CategoryItem'
import TagItemMini from './TagItemMini'

Expand All @@ -13,7 +14,8 @@ import TagItemMini from './TagItemMini'
* @returns
*/
const PostItemCardTop = ({ post, showSummary }) => {
const showPreview = siteConfig('MAGZINE_POST_LIST_PREVIEW') && post?.blockMap
const showPreview =
siteConfig('MAGZINE_POST_LIST_PREVIEW', true, CONFIG) && post?.blockMap
const { locale } = useGlobal()
return (
<div
Expand All @@ -24,24 +26,24 @@ const PostItemCardTop = ({ post, showSummary }) => {
// data-aos-anchor-placement='top-bottom'
className='mb-6 max-w-screen-3xl '>
<div className='flex flex-col w-full'>
{siteConfig('MAGZINE_POST_LIST_COVER') && post?.pageCoverThumbnail && (
<Link
href={post?.href || ''}
passHref
className={
'cursor-pointer hover:underline text-4xl leading-tight dark:text-gray-300 dark:hover:text-gray-400'
}>
<div className='w-full max-h-80 object-cover overflow-hidden mb-2'>
<LazyImage
priority
alt={post?.title}
src={post?.pageCoverThumbnail}
style={post?.pageCoverThumbnail ? {} : { height: '0px' }}
className='w-full max-h-80 object-cover hover:scale-125 duration-150'
/>
</div>
</Link>
)}
{siteConfig('MAGZINE_POST_LIST_COVER', true, CONFIG) &&
post?.pageCoverThumbnail && (
<Link
href={post?.href || ''}
passHref
className={
'cursor-pointer hover:underline text-4xl leading-tight dark:text-gray-300 dark:hover:text-gray-400'
}>
<div className='w-full h-80 object-cover overflow-hidden mb-2'>
<LazyImage
priority
alt={post?.title}
src={post?.pageCoverThumbnail}
className='w-full h-80 object-cover hover:scale-125 duration-150'
/>
</div>
</Link>
)}

<div className='flex py-2 mr-2 items-center'>
{siteConfig('MAGZINE_POST_LIST_CATEGORY') && (
Expand Down
3 changes: 2 additions & 1 deletion themes/magzine/components/PostListRecommend.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { siteConfig } from '@/lib/config'
import CONFIG from '../config'
import PostItemCard from './PostItemCard'
import PostListEmpty from './PostListEmpty'
import Swiper from './Swiper'
Expand All @@ -16,7 +17,7 @@ const PostListRecommend = ({ latestPosts, allNavPages }) => {
if (!recommendPosts || recommendPosts.length === 0) {
return <PostListEmpty />
}
const title = siteConfig('MAGZINE_RECOMMEND_POST_TITLE')
const title = siteConfig('MAGZINE_RECOMMEND_POST_TITLE', '', CONFIG)

return (
<div className={`w-full py-10 px-2 bg-[#F6F6F1] dark:bg-black`}>
Expand Down
109 changes: 0 additions & 109 deletions themes/magzine/components/TopNavBar.js

This file was deleted.

Loading

0 comments on commit fb96bc7

Please sign in to comment.