show not found error on missing slugs
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
import { graphql } from "@/gql";
|
||||
import { NewsFragment } from "@/gql/graphql";
|
||||
import { getClient } from "@/app/client";
|
||||
import { Blocks } from "@/components/blocks/Blocks";
|
||||
import Image from "@/components/general/Image";
|
||||
import { formatDate, commonDateFormat } from "@/lib/date";
|
||||
import { graphql } from "@/gql";
|
||||
import { NewsFragment } from "@/gql/graphql";
|
||||
import { commonDateFormat, formatDate } from "@/lib/date";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const allNewsSlugsQuery = graphql(`
|
||||
@ -40,6 +41,10 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
||||
slug: params.slug,
|
||||
});
|
||||
|
||||
if (data?.news === null || error) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
const news = (data?.news ?? {}) as NewsFragment;
|
||||
const featuredImage: any = news.featuredImage;
|
||||
|
||||
|
Reference in New Issue
Block a user