From 718fbfdacba6ed767825343e465ba6ac35c3f84b Mon Sep 17 00:00:00 2001 From: Timo Clasen Date: Sat, 21 Oct 2023 21:28:44 +0200 Subject: [PATCH] Add Option to Hide Projects --- apps/content/schemas/project.ts | 6 ++++++ apps/website/src/app/projects/page.tsx | 7 ++++--- apps/website/src/lib/queries.ts | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/content/schemas/project.ts b/apps/content/schemas/project.ts index b8b3a13..56f8dda 100644 --- a/apps/content/schemas/project.ts +++ b/apps/content/schemas/project.ts @@ -20,6 +20,12 @@ export const project = defineType({ source: "title", }, }), + defineField({ + name: "hidden", + title: "Hidden", + type: "boolean", + initialValue: false, + }), defineField({ name: "image", title: "Titelbild", diff --git a/apps/website/src/app/projects/page.tsx b/apps/website/src/app/projects/page.tsx index 47c56db..30aaf48 100644 --- a/apps/website/src/app/projects/page.tsx +++ b/apps/website/src/app/projects/page.tsx @@ -66,10 +66,11 @@ const ProjectsPage = async ({ searchParams = {} }: Props) => { const { sort } = sortSchema.parse(searchParams); const projects = await getProjects(); + const filteredProjects = projects.filter((project) => !project.hidden); const services = Array.from( new Set( - projects + filteredProjects .map((project) => { return project.services ? project.services.map((service) => service.title) @@ -81,7 +82,7 @@ const ProjectsPage = async ({ searchParams = {} }: Props) => { const topics = Array.from( new Set( - projects + filteredProjects .map((project) => { return project.topics ? project.topics.map((topic) => topic.title) @@ -102,7 +103,7 @@ const ProjectsPage = async ({ searchParams = {} }: Props) => { - + ); diff --git a/apps/website/src/lib/queries.ts b/apps/website/src/lib/queries.ts index 8f3ecd1..bf87fca 100644 --- a/apps/website/src/lib/queries.ts +++ b/apps/website/src/lib/queries.ts @@ -308,6 +308,7 @@ const projectSchema = z.object({ _id: z.string(), slug: z.string(), title: z.string(), + hidden: z.boolean().nullable(), summary: z.string().nullable(), image: z.object({ url: z.string(), @@ -349,6 +350,7 @@ export const getProjects = async () => { _id, 'slug': slug.current, title, + hidden, summary, image{'url': asset->url, alt, border}, context, @@ -373,6 +375,7 @@ export const getProject = async (slug: string) => { _id, 'slug': slug.current, title, + hidden, summary, image{'url': asset->url, alt, border}, context,