diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2026-01-30 20:45:07 +0100 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2026-01-30 20:45:07 +0100 |
| commit | 650249e1a8fe7d6645bb712026930dd7e8906ef8 (patch) | |
| tree | 4a4f5c46c72f7b8b0f6bef21ce6938e8a8978084 /src/components | |
| parent | 2345a208663efff76837d1228bf14b8847f3177f (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/components')
| -rw-r--r-- | src/components/blog/PostNavigation.astro | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/components/blog/PostNavigation.astro b/src/components/blog/PostNavigation.astro new file mode 100644 index 0000000..037836f --- /dev/null +++ b/src/components/blog/PostNavigation.astro @@ -0,0 +1,39 @@ +--- +import type { CollectionEntry } from "astro:content"; +import { t } from "@/i18n/translations"; + +interface Props { + prevPost: CollectionEntry<"post"> | null | undefined; + nextPost: CollectionEntry<"post"> | null | undefined; + language?: string | undefined; +} + +const { prevPost, nextPost, language } = Astro.props; +--- + +{ + (prevPost || nextPost) && ( + <nav aria-label="Post navigation" class="mt-8 flex items-center gap-x-4"> + {prevPost && ( + <a + class="hover:text-accent me-auto py-2" + data-astro-prefetch + href={`/posts/${prevPost.id}/`} + > + <span class="sr-only">{t(language, "newerPostSr")}</span> + {t(language, "newerPost")} + </a> + )} + {nextPost && ( + <a + class="hover:text-accent ms-auto py-2" + data-astro-prefetch + href={`/posts/${nextPost.id}/`} + > + <span class="sr-only">{t(language, "olderPostSr")}</span> + {t(language, "olderPost")} + </a> + )} + </nav> + ) +} |
