diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 122efb0c..9a1dff7c 100755 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -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) diff --git a/themes/gitbook/components/MenuItemDrop.js b/themes/gitbook/components/MenuItemDrop.js index c3636ba0..6c197700 100644 --- a/themes/gitbook/components/MenuItemDrop.js +++ b/themes/gitbook/components/MenuItemDrop.js @@ -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