diff --git a/themes/gitbook/components/NavPostList.js b/themes/gitbook/components/NavPostList.js index e43d0498..1dff3722 100644 --- a/themes/gitbook/components/NavPostList.js +++ b/themes/gitbook/components/NavPostList.js @@ -15,7 +15,7 @@ const NavPostList = (props) => { let selectedSth = false // 处理是否选中 - filteredPostGroups.map((group) => { + filteredPostGroups?.map((group) => { let groupSelected = false for (const post of group?.items) { if (router.asPath.split('?')[0] === '/' + post.slug) { @@ -28,7 +28,7 @@ const NavPostList = (props) => { }) // 如果都没有选中默认打开第一个 - if (!selectedSth && filteredPostGroups && filteredPostGroups.length > 0) { + if (!selectedSth && filteredPostGroups && filteredPostGroups?.length > 0) { filteredPostGroups[0].selected = true } diff --git a/themes/gitbook/components/PageNavDrawer.js b/themes/gitbook/components/PageNavDrawer.js index 4cad9448..b754b9bd 100644 --- a/themes/gitbook/components/PageNavDrawer.js +++ b/themes/gitbook/components/PageNavDrawer.js @@ -10,7 +10,7 @@ import NavPostList from './NavPostList' */ const PageNavDrawer = (props) => { const { pageNavVisible, changePageNavVisible } = useGitBookGlobal() - const { filteredPosts } = props + const { filteredPostGroups } = props const switchVisible = () => { changePageNavVisible(!pageNavVisible) } @@ -23,7 +23,7 @@ const PageNavDrawer = (props) => { ' overflow-y-hidden shadow-card w-72 duration-200 fixed left-1 top-16 rounded py-2 bg-white dark:bg-gray-600'}>