import NavPostListEmpty from './NavPostListEmpty'
import { useRouter } from 'next/router'
import NavPostItem from './NavPostItem'
import CONFIG from '../config'
import Link from 'next/link'
/**
* 博客列表滚动分页
* @param posts 所有文章
* @param tags 所有标签
* @returns {JSX.Element}
* @constructor
*/
const NavPostList = (props) => {
const { customMenu, categoryOptions } = props
// let groupedArray = categoryOptions
// const { filteredNavPages, categoryOptions, categories } = props
// const router = useRouter()
// let selectedSth = false
// let groupedArray = categoryOptions?.map(item) => {
// // let groups = [];
// groupedArray.push({ category: item.name, id: item.id, count: item.count, selected: false,items: [] })
// return groups
// })
// const groupedArray = categoryOptions?.reduce((groups, item) => {
// const categoryName = item?.name ? item?.name : '' // 将category转换为字符串
// // let existingGroup = null
// console.log('categoryOptions => item::')
// console.log(item)
// // 添加数据
// groups.push({ category: item.name, id: item.id, count: item.count, selected: false, items: [] })
// return groups
// }, [])
// 处理是否选中
// groupedArray?.map((group) => {
// let groupSelected = false
// for (const post of group?.items) {
// if (router.asPath.split('?')[0] === '/' + post.slug) {
// groupSelected = true
// selectedSth = true
// }
// }
// group.selected = groupSelected
// return null
// })
// 如果都没有选中默认打开第一个
// if (!selectedSth && groupedArray && groupedArray?.length > 0) {
// groupedArray[0].selected = true
// }
// console.log('groupedArray::')
// console.log(groupedArray)
// 如果 开启自定义菜单,则覆盖Page生成的菜单
// if (BLOG.CUSTOM_MENU) {
// links = customMenu
// }
let links = customMenu
return
{links && links?.map((link, index) =>