标签加入颜色,修复编译问题
This commit is contained in:
tangly1024
2021-12-01 09:59:50 +08:00
parent 1e24789a24
commit 85f5c266b1
7 changed files with 54 additions and 35 deletions

View File

@@ -14,14 +14,14 @@ const LatestPosts = ({ posts }) => {
// 时间排序
postsSortByDate.sort((a, b) => {
const dateA = new Date(a?.lastEditedTime || a.createdTime)
const dateB = new Date(b?.lastEditedTime || b.createdTime)
return dateB - dateA
const dateA = new Date(a?.lastEditedTime || a.createdTime)
const dateB = new Date(b?.lastEditedTime || b.createdTime)
return dateB - dateA
})
// 只取前五
postsSortByDate = postsSortByDate.slice(0, 5)
// 获取当前路径
const currentPath = useRouter().asPath
@@ -33,12 +33,14 @@ const LatestPosts = ({ posts }) => {
<div>
{postsSortByDate.map(post => {
return (
<Link key={post.id} title={post.title} href={`${BLOG.path}/article/${post.slug}`} >
<div className={(currentPath === `${BLOG.path}/article/${post.slug}` ? 'bg-gray-200 dark:bg-black' : '') + ' text-xs leading-5 py-1.5 px-5 flex'}>
<Link key={post.id} title={post.title} href={`${BLOG.path}/article/${post.slug}`}>
<div
className={(currentPath === `${BLOG.path}/article/${post.slug}` ? 'bg-gray-200 dark:bg-black' : '') + ' text-xs leading-5 py-1.5 px-5 flex'}>
<div className='mr-2 text-gray-500'>
{formatDateFmt(post.lastEditedTime, 'yyyy/MM/dd')}
</div>
<div className='text-sm flex w-50 overflow-x-hidden whitespace-nowrap dark:text-gray-300 cursor-pointer hover:underline'>
<div
className='text-sm flex w-50 overflow-x-hidden whitespace-nowrap dark:text-gray-300 cursor-pointer hover:underline'>
{post.title}
</div>
</div>