Skip to content

Commit

Permalink
add groq query to fetch clubs (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
waalbert authored Oct 28, 2024
1 parent 9a0cd33 commit dce4dac
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions apps/site/src/app/(home)/sections/Clubs/getClubs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { z } from "zod";
import { cache } from "react";
import { client } from "@/lib/sanity/client";
import { SanityDocument, SanityImageReference } from "@/lib/sanity/types";

const Clubs = SanityDocument.extend({
clubs: z.array(
z.object({
_type: z.literal("club"),
_key: z.string(),
name: z.string(),
url: z.string().url().optional(),
logo: SanityImageReference,
}),
),
});

export const getClubs = cache(async () => {
return Clubs.parse(await client.fetch("*[_id == 'clubs'][0]"));
});

0 comments on commit dce4dac

Please sign in to comment.