diff --git a/components/LatestPosts.js b/components/LatestPosts.js
index 603e6bbd..b5caaf1f 100644
--- a/components/LatestPosts.js
+++ b/components/LatestPosts.js
@@ -9,15 +9,21 @@ import { useRouter } from 'next/router'
* @constructor
*/
const LatestPosts = ({ posts }) => {
- // 按时间排序
- if (posts) {
- posts = posts.sort((a, b) => {
+ // 深拷贝
+ let postsSortByDate = Object.create(posts)
+
+ // 时间排序
+ postsSortByDate.sort((a, b) => {
const dateA = new Date(a?.lastEditedTime || a.createdTime)
const dateB = new Date(b?.lastEditedTime || b.createdTime)
return dateB - dateA
- }).slice(0, 5)
- }
- const router = useRouter()
+ })
+
+ // 只取前五
+ postsSortByDate = postsSortByDate.slice(0, 5)
+
+ // 获取当前路径
+ const currentPath = useRouter().asPath
return <>