diff --git a/.hintrc b/.hintrc new file mode 100644 index 0000000..aa8de6b --- /dev/null +++ b/.hintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "development" + ] +} \ No newline at end of file diff --git a/app/blogs/[slug]/page.jsx b/app/blogs/[slug]/page.jsx index 325cde3..798cae8 100644 --- a/app/blogs/[slug]/page.jsx +++ b/app/blogs/[slug]/page.jsx @@ -1,7 +1,7 @@ import { client, urlFor } from "../../../lib/sanity"; import Image from "next/image"; import React from "react"; -import { PortableText, PortableTextComponents } from "@portabletext/react"; +import { PortableText } from "@portabletext/react"; import Link from "next/link"; import { ArrowLeft } from "lucide-react"; @@ -16,7 +16,10 @@ const getData = async (slug) => { titleImage }[0]`; const data = await client.fetch(query); - return data; + if (!data) { + throw new Error("Blog post not found"); + } + return data; }; const components = { @@ -37,6 +40,9 @@ const components = { const page = async ({ params }) => { const data = await getData(params.slug); + if (!data) { + return