mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-20 15:09:40 +00:00
Merge branch 'main' into release/4.0.0
This commit is contained in:
@@ -10,13 +10,12 @@ import NavPostItem from './NavPostItem'
|
||||
* @constructor
|
||||
*/
|
||||
const NavPostList = (props) => {
|
||||
const { filteredPosts } = props
|
||||
|
||||
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 +28,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) {
|
||||
if (!filteredPostGroups || filteredPostGroups.length === 0) {
|
||||
return <NavPostListEmpty />
|
||||
} else {
|
||||
return <div id='posts-wrapper' 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>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user