fix: replace broken prev/next links with correct paths (#533)

Nested blog post URLs in the prev/next links were not
updated properly, which resulted in 404 error pages.
This commit updates the outdated URLs to the correct paths.
This commit is contained in:
Sat Naing
2025-06-12 22:51:02 +07:00
committed by GitHub
parent b3680c590a
commit b07ee5cdcc
+6 -5
View File
@@ -69,12 +69,13 @@ const layoutProps = {
/* ========== Prev/Next Posts ========== */ /* ========== Prev/Next Posts ========== */
const allPosts = posts.map(({ data: { title }, id }) => ({ const allPosts = posts.map(({ data: { title }, id, filePath }) => ({
slug: id, id,
title, title,
filePath,
})); }));
const currentPostIndex = allPosts.findIndex(a => a.slug === post.id); const currentPostIndex = allPosts.findIndex(a => a.id === post.id);
const prevPost = currentPostIndex !== 0 ? allPosts[currentPostIndex - 1] : null; const prevPost = currentPostIndex !== 0 ? allPosts[currentPostIndex - 1] : null;
const nextPost = const nextPost =
@@ -125,7 +126,7 @@ const nextPost =
{ {
prevPost && ( prevPost && (
<a <a
href={`/posts/${prevPost.slug}`} href={getPath(prevPost.id, prevPost.filePath)}
class="flex w-full gap-1 hover:opacity-75" class="flex w-full gap-1 hover:opacity-75"
> >
<IconChevronLeft class="inline-block flex-none" /> <IconChevronLeft class="inline-block flex-none" />
@@ -139,7 +140,7 @@ const nextPost =
{ {
nextPost && ( nextPost && (
<a <a
href={`/posts/${nextPost.slug}`} href={getPath(nextPost.id, nextPost.filePath)}
class="flex w-full justify-end gap-1 text-right hover:opacity-75 sm:col-start-2" class="flex w-full justify-end gap-1 text-right hover:opacity-75 sm:col-start-2"
> >
<div> <div>