We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3d98105 commit 3bdac53Copy full SHA for 3bdac53
apps/site/src/app/resources/getResources.ts
@@ -0,0 +1,17 @@
1
+import { z } from "zod";
2
+import { cache } from "react";
3
+import { client } from "@/lib/sanity/client";
4
+import { SanityDocument, SanityReference } from "@/lib/sanity/types";
5
+
6
+const Resources = z.array(
7
+ SanityDocument.extend({
8
+ _type: z.literal("resource"),
9
+ link: z.string(),
10
+ title: z.string(),
11
+ resourceType: SanityReference,
12
+ }),
13
+);
14
15
+export const getResources = cache(async () => {
16
+ return Resources.parse(await client.fetch("*[_type == 'resource']"));
17
+});
0 commit comments