import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { faArchive, faFileAlt } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' 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.PATH}/article/${post.slug}` return (
{post.title}
) })} } export default LatestPostsGroup