Skip to content

Commit

Permalink
Add Option to Hide Projects
Browse files Browse the repository at this point in the history
  • Loading branch information
timoclsn committed Oct 21, 2023
1 parent 1050c78 commit 718fbfd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions apps/content/schemas/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export const project = defineType({
source: "title",
},
}),
defineField({
name: "hidden",
title: "Hidden",
type: "boolean",
initialValue: false,
}),
defineField({
name: "image",
title: "Titelbild",
Expand Down
7 changes: 4 additions & 3 deletions apps/website/src/app/projects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -102,7 +103,7 @@ const ProjectsPage = async ({ searchParams = {} }: Props) => {
<ProjectFilter services={services} topics={topics} />
</Suspense>
</div>
<ProjectList projects={projects} filter={filter} sort={sort} />
<ProjectList projects={filteredProjects} filter={filter} sort={sort} />
</Container>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions apps/website/src/lib/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -349,6 +350,7 @@ export const getProjects = async () => {
_id,
'slug': slug.current,
title,
hidden,
summary,
image{'url': asset->url, alt, border},
context,
Expand All @@ -373,6 +375,7 @@ export const getProject = async (slug: string) => {
_id,
'slug': slug.current,
title,
hidden,
summary,
image{'url': asset->url, alt, border},
context,
Expand Down

0 comments on commit 718fbfd

Please sign in to comment.