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 { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
import { Blocks } from "@/components/blocks/Blocks";
|
||||||
import Image from "@/components/general/Image";
|
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() {
|
export async function generateStaticParams() {
|
||||||
const allNewsSlugsQuery = graphql(`
|
const allNewsSlugsQuery = graphql(`
|
||||||
@ -40,6 +41,10 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (data?.news === null || error) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
const news = (data?.news ?? {}) as NewsFragment;
|
const news = (data?.news ?? {}) as NewsFragment;
|
||||||
const featuredImage: any = news.featuredImage;
|
const featuredImage: any = news.featuredImage;
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { graphql } from "@/gql";
|
|
||||||
import { EventFragment } from "@/gql/graphql";
|
|
||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
import { Blocks } from "@/components/blocks/Blocks";
|
||||||
import Image from "@/components/general/Image";
|
|
||||||
import { EventHeader } from "@/components/events/EventHeader";
|
|
||||||
import { DateList } from "@/components/events/DateList";
|
import { DateList } from "@/components/events/DateList";
|
||||||
|
import { EventHeader } from "@/components/events/EventHeader";
|
||||||
import { BgPig } from "@/components/general/BgPig";
|
import { BgPig } from "@/components/general/BgPig";
|
||||||
|
import { graphql } from "@/gql";
|
||||||
|
import { EventFragment } from "@/gql/graphql";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const allEventSlugsQuery = graphql(`
|
const allEventSlugsQuery = graphql(`
|
||||||
@ -42,6 +42,10 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (data?.event === null || error) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
const event = (data?.event ?? {}) as EventFragment;
|
const event = (data?.event ?? {}) as EventFragment;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { graphql } from "@/gql";
|
|
||||||
import { AssociationFragment } from "@/gql/graphql";
|
|
||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
import { Blocks } from "@/components/blocks/Blocks";
|
||||||
import Image from "@/components/general/Image";
|
import Image from "@/components/general/Image";
|
||||||
|
import { graphql } from "@/gql";
|
||||||
|
import { AssociationFragment } from "@/gql/graphql";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const allAssociationSlugsQuery = graphql(`
|
const allAssociationSlugsQuery = graphql(`
|
||||||
@ -42,6 +43,10 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (data?.association === null || error) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
const association = (data?.association ?? {}) as AssociationFragment;
|
const association = (data?.association ?? {}) as AssociationFragment;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { graphql } from "@/gql";
|
|
||||||
import { VenueFragment } from "@/gql/graphql";
|
|
||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
import { Blocks } from "@/components/blocks/Blocks";
|
||||||
import Image from "@/components/general/Image";
|
import Image from "@/components/general/Image";
|
||||||
|
import { graphql } from "@/gql";
|
||||||
|
import { VenueFragment } from "@/gql/graphql";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const allVenueSlugsQuery = graphql(`
|
const allVenueSlugsQuery = graphql(`
|
||||||
@ -39,8 +40,12 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (data?.venue === null || error) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
const venue = (data?.venue ?? {}) as VenueFragment;
|
const venue = (data?.venue ?? {}) as VenueFragment;
|
||||||
const featuredImage: any = venue.featuredImage
|
const featuredImage: any = venue.featuredImage;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
|
Reference in New Issue
Block a user