-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c24d38e
commit e32ca96
Showing
6 changed files
with
79 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import LazyImage from '@/components/LazyImage' | ||
import { siteConfig } from '@/lib/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 PostGroupLatest = props => { | ||
const { latestPosts } = props | ||
// 获取当前路径 | ||
const currentPath = useRouter().asPath | ||
const { locale, siteInfo } = useGlobal() | ||
if (!latestPosts) { | ||
return <></> | ||
} | ||
|
||
return ( | ||
<> | ||
{/* 标题 */} | ||
<div className=' mb-2 px-1 flex flex-nowrap justify-between'> | ||
<div className='font-bold text-lg'>{locale.COMMON.LATEST_POSTS}</div> | ||
</div> | ||
|
||
{/* 文章列表 */} | ||
<div className='grid grid-cols-1 lg:grid-cols-4'> | ||
{latestPosts.map(post => { | ||
const selected = | ||
currentPath === `${siteConfig('SUB_PATH', '')}/${post.slug}` | ||
|
||
const headerImage = post?.pageCoverThumbnail | ||
? post.pageCoverThumbnail | ||
: siteInfo?.pageCover | ||
|
||
return ( | ||
<Link | ||
key={post.id} | ||
title={post.title} | ||
href={`${siteConfig('SUB_PATH', '')}/${post.slug}`} | ||
passHref | ||
className={'my-3 flex'}> | ||
<div className='w-20 h-14 overflow-hidden relative'> | ||
<LazyImage | ||
src={`${headerImage}`} | ||
className='object-cover w-full h-full' | ||
/> | ||
</div> | ||
<div | ||
className={ | ||
(selected ? ' text-green-400 ' : 'dark:text-gray-400 ') + | ||
' text-sm overflow-x-hidden hover:text-green-600 px-2 duration-200 w-full rounded ' + | ||
' hover:text-green-400 cursor-pointer items-center flex' | ||
}> | ||
<div> | ||
<div className='line-clamp-2 menu-link'>{post.title}</div> | ||
<div className='text-gray-500'>{post.lastEditedDay}</div> | ||
</div> | ||
</div> | ||
</Link> | ||
) | ||
})} | ||
</div> | ||
</> | ||
) | ||
} | ||
export default PostGroupLatest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters