From fc33828afc054489a4e9192ef897640ab955e9e5 Mon Sep 17 00:00:00 2001 From: shadcn Date: Thu, 3 Nov 2022 12:05:41 +0400 Subject: [PATCH] fix: handle not found errors for posts --- app/(marketing)/blog/[...slug]/page.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/(marketing)/blog/[...slug]/page.tsx b/app/(marketing)/blog/[...slug]/page.tsx index 6ee2112..1c94527 100644 --- a/app/(marketing)/blog/[...slug]/page.tsx +++ b/app/(marketing)/blog/[...slug]/page.tsx @@ -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 (