summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2026-01-30 20:45:07 +0100
committerDawid Rycerz <dawid@rycerz.xyz>2026-01-30 20:45:07 +0100
commit650249e1a8fe7d6645bb712026930dd7e8906ef8 (patch)
tree4a4f5c46c72f7b8b0f6bef21ce6938e8a8978084 /src/pages
parent2345a208663efff76837d1228bf14b8847f3177f (diff)
feat(blog): add next/previous post navigation scoped by category
Navigate between posts within the same category (regular, microblog, archived). Newer post links left, older post links right. Includes i18n support for English and Polish. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/posts/[...slug].astro17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro
index 76e4f28..b66d911 100644
--- a/src/pages/posts/[...slug].astro
+++ b/src/pages/posts/[...slug].astro
@@ -1,24 +1,27 @@
---
import { render } from "astro:content";
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
-import { getAllPosts } from "@/data/post";
+import { getAllPosts, getPostNavigation } from "@/data/post";
import PostLayout from "@/layouts/BlogPost.astro";
// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr
export const getStaticPaths = (async () => {
const blogEntries = await getAllPosts(true); // Include archived posts for direct access
- return blogEntries.map((post) => ({
- params: { slug: post.id },
- props: { post },
- }));
+ return blogEntries.map((post) => {
+ const { prevPost, nextPost } = getPostNavigation(blogEntries, post);
+ return {
+ params: { slug: post.id },
+ props: { post, prevPost, nextPost },
+ };
+ });
}) satisfies GetStaticPaths;
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
-const { post } = Astro.props;
+const { post, prevPost, nextPost } = Astro.props;
const { Content } = await render(post);
---
-<PostLayout post={post}>
+<PostLayout post={post} prevPost={prevPost} nextPost={nextPost}>
<Content />
</PostLayout>