fix: handle not found errors for posts

This commit is contained in:
shadcn 2022-11-03 12:05:41 +04:00
parent 9b08f1051c
commit fc33828afc

View file

@ -1,3 +1,5 @@
import { notFound } from "next/navigation"
import { Blog } from "@/lib/mdx/sources"
import { MdxContent } from "@/components/mdx-content"
import { formatDate } from "@/lib/utils"
@ -21,6 +23,10 @@ export async function generateStaticParams() {
export default async function PostPage({ params }) {
const post = await Blog.getMdxNode(params?.slug?.join("/"))
if (!post) {
notFound()
}
return (
<article className="mx-auto max-w-2xl py-12">
<div className="flex flex-col space-y-2">