diff --git a/components/BlogPostCard.js b/components/BlogPostCard.js
index ae49f8d0..4be89176 100644
--- a/components/BlogPostCard.js
+++ b/components/BlogPostCard.js
@@ -26,7 +26,7 @@ const BlogPostCard = ({ post, tags }) => {
+ className='cursor-pointer dark:text-gray-200 text-gray-500 text-sm py-1.5 mr-1 hover:underline hover:scale-105 transform duration-200'>
{post.category}
diff --git a/components/CategoryGroup.js b/components/CategoryGroup.js
index 0b20eddc..8ce7f074 100644
--- a/components/CategoryGroup.js
+++ b/components/CategoryGroup.js
@@ -5,8 +5,9 @@ const CategoryGroup = ({ currentCategory, categories }) => {
return
{Object.keys(categories).map(category => {
+ const selected = currentCategory === category
return
-
{category}({categories[category]})
+
{category}({categories[category]})
})}
diff --git a/components/LatestPosts.js b/components/LatestPostsGroup.js
similarity index 52%
rename from components/LatestPosts.js
rename to components/LatestPostsGroup.js
index ac8e94b9..c52b2fdd 100644
--- a/components/LatestPosts.js
+++ b/components/LatestPostsGroup.js
@@ -6,10 +6,11 @@ import { useGlobal } from '@/lib/global'
/**
* 最新文章列表
- * @param posts
+ * @param posts 所有文章数据
+ * @param sliceCount 截取展示的数量 默认6
* @constructor
*/
-const LatestPosts = ({ posts }) => {
+const LatestPostsGroup = ({ posts, sliceCount = 6 }) => {
// 深拷贝
let postsSortByDate = Object.create(posts)
@@ -21,28 +22,26 @@ const LatestPosts = ({ posts }) => {
})
// 只取前五
- postsSortByDate = postsSortByDate.slice(0, 5)
+ postsSortByDate = postsSortByDate.slice(0, sliceCount)
// 获取当前路径
const currentPath = useRouter().asPath
- const { locale } = useGlobal()
- return <>
-
- {locale.COMMON.LATEST_POSTS}
-
-
+ return
{postsSortByDate.map(post => {
+ const selected = currentPath === `${BLOG.path}/article/${post.slug}`
return (
-
- {formatDateFmt(post.lastEditedTime, 'yyyy/MM/dd')}
+ className={(selected ? 'bg-gray-200 dark:bg-black ' : '') + ' text-xs leading-5 py-1.5 px-5 flex'}>
+
+ {formatDateFmt(post.lastEditedTime, 'MM/dd')}
+ className={
+ (selected ? 'dark:text-white text-black ' : 'text-gray-500 ') +
+ ' text-sm flex w-50 overflow-x-hidden whitespace-nowrap hover:text-black dark:hover:text-white cursor-pointer hover:underline'
+ }>
{post.title}
@@ -50,6 +49,5 @@ const LatestPosts = ({ posts }) => {
)
})}
- >
}
-export default LatestPosts
+export default LatestPostsGroup
diff --git a/components/MenuButtonGroup.js b/components/MenuButtonGroup.js
index d4b34c5d..07345f7e 100644
--- a/components/MenuButtonGroup.js
+++ b/components/MenuButtonGroup.js
@@ -19,20 +19,22 @@ const MenuButtonGroup = ({ allowCollapse = false }) => {
// { id: 9, icon: 'fa-telegram', name: 'Telegram', to: 'https://t.me/tangly_1024', show: true }
]
return