Skip to content

Commit

Permalink
fix: handle not found errors for posts
Browse files Browse the repository at this point in the history
  • Loading branch information
shadcn committed Nov 3, 2022
1 parent 9b08f10 commit fc33828
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/(marketing)/blog/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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">
Expand Down

0 comments on commit fc33828

Please sign in to comment.