fix: 修正博客导航中上一篇和下一篇文章的索引逻辑

This commit is contained in:
joyzhao
2026-01-09 09:39:20 +08:00
parent 51eac1c2ef
commit 551877780f

View File

@@ -64,8 +64,8 @@ const sortedPosts = posts
const currentIndex = sortedPosts.findIndex((post) => post.slug === currentSlug);
const nextPost = currentIndex > 0 ? sortedPosts[currentIndex - 1] : null;
const prevPost = currentIndex < sortedPosts.length - 1 ? sortedPosts[currentIndex + 1] : null;
const nextPost = currentIndex < sortedPosts.length - 1 ? sortedPosts[currentIndex + 1] : null;
const prevPost = currentIndex > 0 ? sortedPosts[currentIndex - 1] : null;
const prevText = lang === 'zh' ? '上一篇' : 'Previous Post';
const nextText = lang === 'zh' ? '下一篇' : 'Next Post';