Skip to content

Commit

Permalink
Add sanity schema for clubs (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
waalbert authored Oct 28, 2024
1 parent e00186d commit 9a0cd33
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 7 deletions.
25 changes: 19 additions & 6 deletions apps/sanity/sanity.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineConfig } from "sanity";
import { deskTool } from "sanity/desk";
import { structureTool } from "sanity/structure";
import { visionTool } from "@sanity/vision";
import { colorInput } from "@sanity/color-input";
import { media } from "sanity-plugin-media";
import { schemaTypes } from "./schemas";
import { HeartHandshake, BadgeHelp } from "lucide-react";
import { HeartHandshake, BadgeHelp, Handshake } from "lucide-react";

export default defineConfig({
name: "default",
Expand All @@ -14,7 +14,7 @@ export default defineConfig({
dataset: "production",

plugins: [
deskTool({
structureTool({
structure: (S) =>
S.list()
.title("Content")
Expand All @@ -26,17 +26,30 @@ export default defineConfig({
S.document()
.schemaType("sponsors")
.documentId("sponsors")
.title("Sponsors")
.title("Sponsors"),
),
S.listItem()
.title("Clubs")
.icon(Handshake)
.child(
S.document()
.schemaType("clubs")
.documentId("clubs")
.title("Clubs"),
),
S.listItem()
.title("FAQs")
.icon(BadgeHelp)
.child(
S.document().schemaType("faqs").documentId("faqs").title("FAQs")
S.document()
.schemaType("faqs")
.documentId("faqs")
.title("FAQs"),
),
S.divider(),
...S.documentTypeListItems().filter(
(listItem) => !["faqs", "sponsors"].includes(listItem.getId()!)
(listItem) =>
!["faqs", "sponsors", "clubs"].includes(listItem.getId()!),
),
]),
}),
Expand Down
41 changes: 41 additions & 0 deletions apps/sanity/schemas/clubs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { defineType, defineField, defineArrayMember } from "sanity";
import { Handshake } from "lucide-react";

export default defineType({
name: "clubs",
title: "Clubs",
type: "document",
icon: Handshake,
fields: [
defineField({
name: "clubs",
title: "Clubs",
type: "array",
of: [
defineArrayMember({
type: "object",
name: "club",
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(),
}),
],
}),
],
}),
],
});
3 changes: 2 additions & 1 deletion apps/sanity/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import faqs from "./faqs";
import event from "./event";
import resource from "./resource";
import sponsors from "./sponsors";
import clubs from "./clubs";

export const schemaTypes = [faqs, event, resource, sponsors];
export const schemaTypes = [faqs, event, resource, sponsors, clubs];

0 comments on commit 9a0cd33

Please sign in to comment.