import of old blog posts
Some checks failed
Build and Deploy Blog / build-and-deploy-local (push) Failing after 27s
Some checks failed
Build and Deploy Blog / build-and-deploy-local (push) Failing after 27s
This commit is contained in:
10
lib/posts.ts
10
lib/posts.ts
@@ -89,6 +89,16 @@ export function getAllPostIds() {
|
||||
}
|
||||
}
|
||||
|
||||
export function getAdjacentPosts(slug: string): { prev: PostMeta | null; next: PostMeta | null } {
|
||||
const posts = getSortedPostsData(); // newest → oldest
|
||||
const index = posts.findIndex((p) => p.id === slug);
|
||||
if (index === -1) return { prev: null, next: null };
|
||||
return {
|
||||
prev: posts[index + 1] ?? null, // older
|
||||
next: posts[index - 1] ?? null, // newer
|
||||
};
|
||||
}
|
||||
|
||||
export async function getPostData(id: string): Promise<PostData> {
|
||||
const fullPath = path.join(postsDirectory, `${id}.mdx`);
|
||||
if (!fs.existsSync(fullPath)) notFound();
|
||||
|
||||
Reference in New Issue
Block a user