Add next/prev links to bottom of blog posts
This commit is contained in:
@@ -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>
|
||||
)
|
||||
|
||||
@@ -914,6 +914,64 @@ h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.post-navigation {
|
||||
margin-top: 48px;
|
||||
padding-top: 24px;
|
||||
border-top: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.post-nav-links {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.post-nav-link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 12px 16px;
|
||||
border-radius: 6px;
|
||||
background-color: var(--sheet-background);
|
||||
border: 1px solid var(--border-color);
|
||||
text-decoration: none;
|
||||
color: var(--text-primary);
|
||||
transition: all 0.2s ease;
|
||||
flex: 1;
|
||||
max-width: 48%;
|
||||
}
|
||||
|
||||
.post-nav-link:hover {
|
||||
background-color: var(--accent-color);
|
||||
color: var(--accent-text-color);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.prev-nav {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.next-nav {
|
||||
align-items: flex-end;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.nav-direction {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
color: var(--accent-color);
|
||||
}
|
||||
|
||||
.post-nav-link:hover .nav-direction {
|
||||
color: var(--accent-text-color);
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* Responsive adjustments */
|
||||
@media (max-width: 1200px) {
|
||||
aside {
|
||||
@@ -1025,16 +1083,24 @@ h1 {
|
||||
}
|
||||
|
||||
.post-content h3 {
|
||||
font-size: 20px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.post-nav-link {
|
||||
padding: 10px 12px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.tag-pills {
|
||||
gap: 6px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.tag-pill {
|
||||
font-size: 12px;
|
||||
padding: 4px 10px;
|
||||
padding: 6px 12px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user