MDX Starter (#3)

Reviewed-on: mthomson/michaelthomson#3
Co-authored-by: Michael Thomson <michael@michaelthomson.dev>
Co-committed-by: Michael Thomson <michael@michaelthomson.dev>
This commit is contained in:
2024-01-18 14:01:49 +00:00
committed by mthomson
parent a9c847ad0b
commit a25eb1d730
8 changed files with 1529 additions and 90 deletions

17
app/blog/[slug]/page.tsx Normal file
View File

@@ -0,0 +1,17 @@
import { getAllPosts, getPostBySlug } from "@/lib/posts";
import { MDXRemote } from 'next-mdx-remote/rsc'
export async function generateStaticParams() {
const posts = getAllPosts(["slug"]);
return posts.map((post) => ({ slug: post.slug }));
}
export default async function Page({ params }: { params: { slug: string } }) {
const post = getPostBySlug(params.slug, ["title", "content"]);
return (
<MDXRemote
source={post.content}
/>
)
}