Add next/prev links to bottom of blog posts

This commit is contained in:
2026-01-09 00:13:23 -08:00
parent cc21c06641
commit 58fa014341
4 changed files with 151 additions and 6 deletions

View File

@@ -1,5 +1,10 @@
import React from 'react';
interface NavigationPost {
title: string;
path: string;
}
interface PostProps {
// HTML string for the blog post body
children: string;
@@ -7,10 +12,14 @@ interface PostProps {
title: string;
date: Date;
readingTime: string;
previousPost?: NavigationPost | null;
nextPost?: NavigationPost | null;
};
}
export function Post({ children, meta }: PostProps) {
const { previousPost, nextPost } = meta;
return (
<main>
<article className="blog-post">
@@ -39,6 +48,22 @@ export function Post({ children, meta }: PostProps) {
</div>
</header>
<div className="post-content" dangerouslySetInnerHTML={{ __html: children }} />
<footer className="post-navigation">
<div className="post-nav-links">
{previousPost && (
<a href={previousPost.path} className="post-nav-link prev-nav">
<span className="nav-direction"> Previous</span>
<span className="nav-title">{previousPost.title}</span>
</a>
)}
{nextPost && (
<a href={nextPost.path} className="post-nav-link next-nav">
<span className="nav-direction">Next </span>
<span className="nav-title">{nextPost.title}</span>
</a>
)}
</div>
</footer>
</article>
</main>
)