Add next/prev links to bottom of blog posts
This commit is contained in:
12
index.tsx
12
index.tsx
@@ -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>,
|
||||
),
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user