diff --git a/app/mitglieder/[slug]/page.tsx b/app/mitglieder/[slug]/page.tsx index 16e3228..376661d 100644 --- a/app/mitglieder/[slug]/page.tsx +++ b/app/mitglieder/[slug]/page.tsx @@ -11,6 +11,7 @@ import { } from "lib/members"; import { createGenerateMetadata } from "lib/metadata"; import Image from "next/image"; +import { notFound } from "next/navigation"; export const generateMetadata = createGenerateMetadata(async ({ params }) => { const { slug } = await params; @@ -39,6 +40,11 @@ interface Props { const MemberPage = async ({ params }: Props) => { const { slug } = await params; const member = await getWebsiteMemberBySlug(slug); + + if (!member) { + notFound(); + } + const otherMembers = await getRandomOtherMembers(member, 5); return ( diff --git a/components/ContactSection.tsx b/components/ContactSection.tsx index 2ef2465..63d5cc4 100644 --- a/components/ContactSection.tsx +++ b/components/ContactSection.tsx @@ -6,6 +6,10 @@ import { MemberImage } from "./MemberImage"; export const ContactSection = async () => { const member = await getWebsiteMemberByName("Nina Kuch"); + if (!member) { + return null; + } + return (
diff --git a/components/TestimonialsSection.tsx b/components/TestimonialsSection.tsx index 5c5415f..8bdf513 100644 --- a/components/TestimonialsSection.tsx +++ b/components/TestimonialsSection.tsx @@ -27,6 +27,10 @@ export const TestimonialsSection = async () => { {testimonials.map(async (testimonial, index) => { const member = await getWebsiteMemberByName(testimonial.data.name); + if (!member) { + return null; + } + return (
  • diff --git a/lib/members.ts b/lib/members.ts index 14a20bd..3488fd0 100644 --- a/lib/members.ts +++ b/lib/members.ts @@ -2,8 +2,7 @@ import kebabCase from "lodash/kebabCase"; import trim from "lodash/trim"; import z from "zod"; import { getCacheValue, setCacheValue } from "./cache"; -import { customField, getActiveMembers, Member } from "./easyverein"; -import { notFound } from "next/navigation"; +import { customField, getActiveMembers } from "./easyverein"; const { NODE_ENV } = process.env; @@ -166,7 +165,7 @@ export const getWebsiteMemberByName = async (name: string) => { if (!member) { console.error(`Member with name "${name}" not found`); - notFound(); + return null; } return member; @@ -178,7 +177,7 @@ export const getWebsiteMemberBySlug = async (slug: string) => { if (!member) { console.error(`Member with slug "${slug}" not found`); - notFound(); + return null; } return member;