import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import Link from 'next/link' import { useRouter } from 'next/router' /** * 最新文章列表 * @param posts 所有文章数据 * @param sliceCount 截取展示的数量 默认6 * @constructor */ const LatestPostsGroup = ({ posts }) => { if (!posts) { return <> } // 获取当前路径 const currentPath = useRouter().asPath const { locale } = useGlobal() return ( <>
{locale.COMMON.LATEST_POSTS}
{posts.map(post => { const selected = currentPath === `${BLOG.SUB_PATH}/article/${post.slug}` return (
{post.title}
) })} ) } export default LatestPostsGroup