菜单bug

This commit is contained in:
tangly1024.com
2024-02-04 17:49:18 +08:00
parent 0b91bfb211
commit e904b47e76
3 changed files with 15 additions and 6 deletions

View File

@@ -119,6 +119,7 @@ export async function getNotionPageData({ pageId, from }) {
/**
* 获取用户自定义单页菜单
* 旧版本不读取Menu菜单而是读取type=Page生成菜单
* @param notionPageData
* @returns {Promise<[]|*[]>}
*/
@@ -126,11 +127,16 @@ function getCustomNav({ allPages }) {
const customNav = []
if (allPages && allPages.length > 0) {
allPages.forEach(p => {
p.to = p.slug
if (p?.slug?.indexOf('http') === 0) {
customNav.push({ icon: p.icon || null, name: p.title, to: p.slug, target: '_blank', show: true })
p.target = '_blank'
} else {
customNav.push({ icon: p.icon || null, name: p.title, to: '/' + p.slug, target: '_self', show: true })
p.target = '_self'
if (p?.slug?.indexOf('/') !== 0) {
p.to = '/' + p.slug
}
}
customNav.push({ icon: p.icon || null, name: p.title, to: p.slug, target: '_blank', show: true })
})
}
return customNav
@@ -149,6 +155,12 @@ function getCustomMenu({ collectionData }) {
e.show = true
if (e?.slug?.indexOf('http') === 0) {
e.target = '_blank'
e.to = e.slug
} else {
e.target = '_self'
if (e?.slug?.indexOf('/') !== 0) {
e.to = '/' + e.slug
}
}
if (e.type === BLOG.NOTION_PROPERTY_NAME.type_menu) {
menus.push(e)

View File

@@ -4,8 +4,6 @@ import { useRouter } from 'next/router'
export const MenuItemDrop = ({ link }) => {
const [show, changeShow] = useState(false)
// const show = true
// const changeShow = () => {}
const router = useRouter()
if (!link || !link.show) {
@@ -13,7 +11,7 @@ export const MenuItemDrop = ({ link }) => {
}
const hasSubMenu = link?.subMenus?.length > 0
const selected = (router.pathname === link.to) || (router.asPath === link.to)
console.log('link', link?.to)
return <li className='cursor-pointer list-none items-center flex mx-2' onMouseOver={() => changeShow(true)} onMouseOut={() => changeShow(false)} >
{hasSubMenu &&

View File

@@ -213,7 +213,6 @@ const LayoutPostList = props => {
*/
const LayoutSlug = (props) => {
const { post, lock, validPassword } = props
return (
<>
{/* 文章锁 */}