fix: 修正博客导航中上一篇和下一篇文章的索引逻辑
This commit is contained in:
@@ -64,8 +64,8 @@ const sortedPosts = posts
|
|||||||
|
|
||||||
const currentIndex = sortedPosts.findIndex((post) => post.slug === currentSlug);
|
const currentIndex = sortedPosts.findIndex((post) => post.slug === currentSlug);
|
||||||
|
|
||||||
const nextPost = currentIndex > 0 ? sortedPosts[currentIndex - 1] : null;
|
const nextPost = currentIndex < sortedPosts.length - 1 ? sortedPosts[currentIndex + 1] : null;
|
||||||
const prevPost = currentIndex < sortedPosts.length - 1 ? sortedPosts[currentIndex + 1] : null;
|
const prevPost = currentIndex > 0 ? sortedPosts[currentIndex - 1] : null;
|
||||||
|
|
||||||
const prevText = lang === 'zh' ? '上一篇' : 'Previous Post';
|
const prevText = lang === 'zh' ? '上一篇' : 'Previous Post';
|
||||||
const nextText = lang === 'zh' ? '下一篇' : 'Next Post';
|
const nextText = lang === 'zh' ? '下一篇' : 'Next Post';
|
||||||
|
|||||||
Reference in New Issue
Block a user