diff --git a/apps/sanity/schemas/index.ts b/apps/sanity/schemas/index.ts index f36c2797..f7f7b8f3 100644 --- a/apps/sanity/schemas/index.ts +++ b/apps/sanity/schemas/index.ts @@ -1,5 +1,6 @@ import faqs from "./faqs"; import event from "./event"; +import partners from "./partners"; import resource from "./resource"; import resourceCategory from "./resourceCategory"; import resourceCategoryOrder from "./resourceCategoryOrder"; @@ -8,6 +9,7 @@ import sponsors from "./sponsors"; export const schemaTypes = [ faqs, event, + partners, resource, resourceCategory, resourceCategoryOrder, diff --git a/apps/sanity/schemas/partners.ts b/apps/sanity/schemas/partners.ts new file mode 100644 index 00000000..7dbda380 --- /dev/null +++ b/apps/sanity/schemas/partners.ts @@ -0,0 +1,41 @@ +import { defineType, defineField, defineArrayMember } from "sanity"; +import { HeartHandshake } from "lucide-react"; + +export default defineType({ + name: "partners", + title: "Partners", + icon: HeartHandshake, + type: "document", + fields: [ + defineField({ + name: "partners", + title: "Partners", + type: "array", + of: [ + defineArrayMember({ + type: "object", + name: "partner", + fields: [ + defineField({ + name: "name", + title: "Name", + type: "string", + validation: (Rule) => Rule.required(), + }), + defineField({ + name: "url", + title: "URL", + type: "url", + }), + defineField({ + name: "logo", + title: "Logo", + type: "image", + validation: (Rule) => Rule.required(), + }), + ], + }), + ], + }), + ], +}); diff --git a/apps/site/src/app/(main)/(home)/page.tsx b/apps/site/src/app/(main)/(home)/page.tsx index cba67b74..a45aa113 100644 --- a/apps/site/src/app/(main)/(home)/page.tsx +++ b/apps/site/src/app/(main)/(home)/page.tsx @@ -1,4 +1,11 @@ -import { About, Landing, MentorVolunteer, FAQ, Sponsors } from "./sections"; +import { + About, + Landing, + MentorVolunteer, + FAQ, + Sponsors, + Partners, +} from "./sections"; export const revalidate = 60; @@ -14,6 +21,7 @@ export default function Home() { + > ); } diff --git a/apps/site/src/app/(main)/(home)/sections/Partners/Partners.module.scss b/apps/site/src/app/(main)/(home)/sections/Partners/Partners.module.scss new file mode 100644 index 00000000..3f271463 --- /dev/null +++ b/apps/site/src/app/(main)/(home)/sections/Partners/Partners.module.scss @@ -0,0 +1,3 @@ +.title { + text-shadow: 0px 0px 20px rgba(255, 255, 255, 0.75); +} diff --git a/apps/site/src/app/(main)/(home)/sections/Partners/Partners.tsx b/apps/site/src/app/(main)/(home)/sections/Partners/Partners.tsx new file mode 100644 index 00000000..7cc2c80e --- /dev/null +++ b/apps/site/src/app/(main)/(home)/sections/Partners/Partners.tsx @@ -0,0 +1,45 @@ +/* eslint-disable @next/next/no-img-element */ +import Image from "next/image"; + +import { getPartners } from "./getPartners"; +import fishingBoat from "@/assets/images/fishing-boat.png"; + +import { client } from "@/lib/sanity/client"; +import imageUrlBuilder from "@sanity/image-url"; + +import styles from "./Partners.module.scss"; + +const builder = imageUrlBuilder(client); + +export default async function Sponsors() { + const partners = await getPartners(); + + return ( + + + Partners + + + {partners.partners.map(({ _key, name, url, logo }) => ( + + {/* eslint-disable-next-line @next/next/no-img-element*/} + + + ))} + + + + ); +} diff --git a/apps/site/src/app/(main)/(home)/sections/Partners/getPartners.ts b/apps/site/src/app/(main)/(home)/sections/Partners/getPartners.ts new file mode 100644 index 00000000..e5b506f5 --- /dev/null +++ b/apps/site/src/app/(main)/(home)/sections/Partners/getPartners.ts @@ -0,0 +1,23 @@ +import { z } from "zod"; +import { cache } from "react"; +import { client } from "@/lib/sanity/client"; +import { SanityDocument, SanityImageReference } from "@/lib/sanity/types"; + +export const Partner = z.object({ + _type: z.literal("partner"), + _key: z.string(), + name: z.string(), + url: z.string().url().optional(), + logo: SanityImageReference, +}); + +const Partners = SanityDocument.extend({ + partners: z.array(Partner), +}); + +export const getPartners = cache(async () => { + const partners = Partners.parse( + await client.fetch("*[_type == 'partners' && _id == 'partners'][0]"), + ); + return partners; +}); diff --git a/apps/site/src/app/(main)/(home)/sections/Sponsors/Sponsors.tsx b/apps/site/src/app/(main)/(home)/sections/Sponsors/Sponsors.tsx index 9d63d762..02b0a6a5 100644 --- a/apps/site/src/app/(main)/(home)/sections/Sponsors/Sponsors.tsx +++ b/apps/site/src/app/(main)/(home)/sections/Sponsors/Sponsors.tsx @@ -1,8 +1,4 @@ -/* eslint-disable @next/next/no-img-element */ -import Image from "next/image"; - import { getSponsors } from "./getSponsors"; -import fishingBoat from "@/assets/images/fishing-boat.png"; import SponsorTier from "./components/SponsorTier/SponsorTier"; import styles from "./Sponsors.module.scss"; @@ -40,7 +36,6 @@ export default async function Sponsors() { ))} - ); } diff --git a/apps/site/src/app/(main)/(home)/sections/index.ts b/apps/site/src/app/(main)/(home)/sections/index.ts index 3642779a..c0fcf279 100644 --- a/apps/site/src/app/(main)/(home)/sections/index.ts +++ b/apps/site/src/app/(main)/(home)/sections/index.ts @@ -2,4 +2,5 @@ export { default as Landing } from "./Landing/Landing"; export { default as About } from "./About/About"; export { default as MentorVolunteer } from "./MentorVolunteer/MentorVolunteer"; export { default as FAQ } from "./FAQ/FAQ"; -export { default as Sponsors } from "./Sponsors/Sponsors" +export { default as Sponsors } from "./Sponsors/Sponsors"; +export { default as Partners } from "./Partners/Partners";