mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-15 15:09:25 +00:00
fix gitbook
This commit is contained in:
@@ -30,14 +30,14 @@ const LayoutBase = (props) => {
|
||||
const { children, meta, post, allNavPages, slotLeft, slotRight, slotTop } = props
|
||||
const [tocVisible, changeTocVisible] = useState(false)
|
||||
const [pageNavVisible, changePageNavVisible] = useState(false)
|
||||
const [filterPosts, setFilterPosts] = useState(allNavPages)
|
||||
const [filteredPostGroups, setFilteredPostGroups] = useState(allNavPages)
|
||||
const { onLoading } = useGlobal()
|
||||
const router = useRouter()
|
||||
|
||||
const showTocButton = post?.toc?.length > 1
|
||||
|
||||
useEffect(() => {
|
||||
setFilterPosts(allNavPages)
|
||||
setFilteredPostGroups(allNavPages)
|
||||
}, [post])
|
||||
|
||||
const LoadingCover = <div id='cover-loading' className={`${onLoading ? 'z-50 opacity-50' : '-z-10 opacity-0'} pointer-events-none transition-all duration-300`}>
|
||||
@@ -47,10 +47,10 @@ const LayoutBase = (props) => {
|
||||
</div>
|
||||
|
||||
return (
|
||||
<ThemeGlobalMedium.Provider value={{ tocVisible, changeTocVisible, filterPosts, setFilterPosts, allNavPages, pageNavVisible, changePageNavVisible }}>
|
||||
<CommonHead meta={meta} />
|
||||
<ThemeGlobalMedium.Provider value={{ tocVisible, changeTocVisible, filteredPostGroups, setFilteredPostGroups, allNavPages, pageNavVisible, changePageNavVisible }}>
|
||||
|
||||
<div id='theme-medium' className='bg-white dark:bg-hexo-black-gray w-full h-full min-h-screen justify-center dark:text-gray-300'>
|
||||
<CommonHead meta={meta} />
|
||||
{/* 顶部导航栏 */}
|
||||
<TopNavBar {...props} />
|
||||
|
||||
@@ -64,7 +64,7 @@ const LayoutBase = (props) => {
|
||||
<SearchInput className='my-3 rounded-md' />
|
||||
|
||||
{/* 所有文章列表 */}
|
||||
<NavPostList posts={filterPosts} />
|
||||
<NavPostList {...props} filteredPostGroups={filteredPostGroups} />
|
||||
|
||||
<div className='mt-2'>
|
||||
<Footer {...props} />
|
||||
@@ -90,7 +90,7 @@ const LayoutBase = (props) => {
|
||||
|
||||
{/* 底部 */}
|
||||
<div className='md:hidden'>
|
||||
<Footer {...props}/>
|
||||
<Footer {...props} />
|
||||
</div>
|
||||
<div className='text-center'>
|
||||
<AdSlot type='native' />
|
||||
|
||||
@@ -27,8 +27,7 @@ export const LayoutIndex = (props) => {
|
||||
}, 7 * 1000)
|
||||
})
|
||||
}, [])
|
||||
return <LayoutBase {...props}>
|
||||
</LayoutBase>
|
||||
return <LayoutBase {...props}/>
|
||||
}
|
||||
|
||||
export default LayoutIndex
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import NavPostListEmpty from './NavPostListEmpty'
|
||||
import { useRouter } from 'next/router'
|
||||
import NavPostItem from './NavPostItem'
|
||||
import { deepClone } from '@/lib/utils'
|
||||
|
||||
/**
|
||||
* 博客列表滚动分页
|
||||
@@ -10,13 +11,12 @@ import NavPostItem from './NavPostItem'
|
||||
* @constructor
|
||||
*/
|
||||
const NavPostList = (props) => {
|
||||
const { posts = [], currentSearch } = props
|
||||
const filteredPosts = Object.assign(posts)
|
||||
const { filteredPostGroups } = props
|
||||
const router = useRouter()
|
||||
let selectedSth = false
|
||||
|
||||
// 处理是否选中
|
||||
filteredPosts.map((group) => {
|
||||
filteredPostGroups?.map((group) => {
|
||||
let groupSelected = false
|
||||
for (const post of group?.items) {
|
||||
if (router.asPath.split('?')[0] === '/' + post.slug) {
|
||||
@@ -29,16 +29,16 @@ const NavPostList = (props) => {
|
||||
})
|
||||
|
||||
// 如果都没有选中默认打开第一个
|
||||
if (!selectedSth && filteredPosts && filteredPosts.length > 0) {
|
||||
filteredPosts[0].selected = true
|
||||
if (!selectedSth && filteredPostGroups && filteredPostGroups.length > 0) {
|
||||
filteredPostGroups[0].selected = true
|
||||
}
|
||||
|
||||
if (!filteredPosts || filteredPosts.length === 0) {
|
||||
return <NavPostListEmpty currentSearch={currentSearch} />
|
||||
if (!filteredPostGroups || filteredPostGroups.length === 0) {
|
||||
return <NavPostListEmpty />
|
||||
} else {
|
||||
return <div className='w-full flex-grow'>
|
||||
{/* 文章列表 */}
|
||||
{filteredPosts?.map((group, index) => <NavPostItem key={index} group={group} onHeightChange={props.onHeightChange}/>)}
|
||||
{filteredPostGroups?.map((group, index) => <NavPostItem key={index} group={group} onHeightChange={props.onHeightChange}/>)}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import NavPostList from './NavPostList'
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const PageNavDrawer = ({ post, cRef }) => {
|
||||
const PageNavDrawer = (props) => {
|
||||
const { pageNavVisible, changePageNavVisible, filterPosts } = useGitBookGlobal()
|
||||
const switchVisible = () => {
|
||||
changePageNavVisible(!pageNavVisible)
|
||||
|
||||
Reference in New Issue
Block a user