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

@@ -6,7 +6,7 @@ import { Home } from "./src/frontend/pages/home";
import { NotFound } from "./src/frontend/pages/not-found";
import demo from "./temp/appshell.html";
import { Post } from "./src/frontend/pages/post";
import { getPostWithTags } from "./src/db/index";
import { getPostWithTags, getAdjacentPosts } from "./src/db/index";
async function blogPosts(hmr: boolean) {
const glob = new Bun.Glob("**/*.md");
@@ -29,12 +29,17 @@ async function blogPosts(hmr: boolean) {
headers: { "Content-Type": "text/html" },
});
// Get adjacent posts for navigation
const { previousPost, nextPost } = getAdjacentPosts(post.path);
const data = {
title: post.title,
summary: post.summary,
date: new Date(post.date),
readingTime: post.reading_time,
tags: post.tags || [],
previousPost,
nextPost,
};
// AppShell is already loaded, just send the <main> content
@@ -53,7 +58,10 @@ async function blogPosts(hmr: boolean) {
return new Response(
renderToString(
<AppShell>
<Post meta={data} children={post.content} />
<Post
meta={data}
children={post.content}
/>
</AppShell>,
),
{