import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' // import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/router' /** * 最新文章列表 * @param posts 所有文章数据 * @param sliceCount 截取展示的数量 默认6 * @constructor */ const LatestPostsGroup = ({ latestPosts, siteInfo }) => { // 获取当前路径 const currentPath = useRouter().asPath const { locale } = useGlobal() if (!latestPosts) { return <> } return <>
{locale.COMMON.LATEST_POSTS}
{latestPosts.map(post => { const selected = currentPath === `${BLOG.SUB_PATH}/${post.slug}` const headerImage = post?.page_cover ? post.page_cover : siteInfo?.pageCover return ( (
{/* {post.title} */} {/* eslint-disable-next-line @next/next/no-img-element */}
{post.title}
{post.lastEditedTime}
) ) })} } export default LatestPostsGroup