summaryrefslogtreecommitdiff
path: root/src/components/blog/PostNavigation.astro
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/blog/PostNavigation.astro')
-rw-r--r--src/components/blog/PostNavigation.astro39
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>
+ )
+}