-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from HackAtUCI/update/resources-sanity
Setup Sanity queries on resources page
- Loading branch information
Showing
9 changed files
with
127 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const revalidate = 60; | ||
|
||
export { Resources as default } from "@/views"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const revalidate = 60; | ||
|
||
export { Schedule as default } from "@/views"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { z } from "zod"; | ||
import { cache } from "react"; | ||
import { client } from "@/lib/sanity/client"; | ||
import { SanityDocument } from "@/lib/sanity/types"; | ||
|
||
const Resources = z.array( | ||
SanityDocument.extend({ | ||
description: z.array( | ||
z.object({ | ||
_key: z.string(), | ||
markDefs: z.array( | ||
z.object({ | ||
_type: z.string(), | ||
href: z.optional(z.string()), | ||
_key: z.string(), | ||
}), | ||
), | ||
children: z.array( | ||
z.object({ | ||
text: z.string(), | ||
_key: z.string(), | ||
_type: z.literal("span"), | ||
marks: z.array(z.string()), | ||
}), | ||
), | ||
_type: z.literal("block"), | ||
style: z.literal("normal"), | ||
}), | ||
), | ||
resourceType: z.string(), | ||
link: z.string(), | ||
logo: z.object({ | ||
_type: z.string(), | ||
asset: z.object({ | ||
_ref: z.string(), | ||
_type: z.literal("reference"), | ||
}), | ||
}), | ||
stickyNoteColor: z.object({ | ||
_type: z.literal("color"), | ||
alpha: z.number(), | ||
hex: z.string(), | ||
}), | ||
title: z.string(), | ||
}), | ||
); | ||
|
||
export const getResources = cache(async (resourceType: string) => { | ||
return Resources.parse( | ||
await client.fetch( | ||
`*[_type == 'resource' && resourceType == '${resourceType}']`, | ||
), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters