Skip to content

Commit

Permalink
Copy over ZotHacks Sanity schemas (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
waalbert authored Nov 12, 2023
1 parent 38e40fa commit 3528ad0
Show file tree
Hide file tree
Showing 7 changed files with 1,437 additions and 703 deletions.
76 changes: 39 additions & 37 deletions apps/sanity/package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
{
"name": "irvinehacks-site-2024",
"private": true,
"version": "1.0.0",
"main": "package.json",
"license": "UNLICENSED",
"scripts": {
"dev": "sanity dev",
"start": "sanity start",
"build": "sanity build",
"deploy": "sanity deploy",
"deploy-graphql": "sanity graphql deploy"
},
"keywords": [
"sanity"
],
"dependencies": {
"@sanity/vision": "^3.19.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"sanity": "^3.19.2",
"styled-components": "^6.0.7"
},
"devDependencies": {
"@sanity/eslint-config-studio": "^3.0.1",
"@types/react": "^18.0.25",
"eslint": "^8.6.0",
"prettier": "^3.0.2",
"typescript": "^5.1.6"
},
"prettier": {
"semi": false,
"printWidth": 100,
"bracketSpacing": false,
"singleQuote": true
}
}
"name": "sanity",
"private": true,
"version": "1.0.0",
"main": "package.json",
"scripts": {
"dev": "sanity dev",
"start": "sanity start",
"build": "sanity build",
"deploy": "sanity deploy",
"deploy-graphql": "sanity graphql deploy",
"lint": "eslint .",
"format:write": "prettier --write .",
"format:check": "prettier --check ."
},
"keywords": [
"sanity"
],
"dependencies": {
"@portabletext/react": "^3.0.7",
"@sanity/color-input": "^3.1.0",
"@sanity/vision": "^3.15.1",
"lucide-react": "^0.271.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"sanity": "^3.15.1",
"sanity-plugin-media": "^2.2.2",
"styled-components": "^5.3.9"
},
"devDependencies": {
"@sanity/eslint-config-studio": "^3.0.0",
"@types/react": "^18.0.25",
"@types/styled-components": "^5.1.26",
"eslint": "^8.6.0",
"eslint-plugin-sanity-studio": "^0.4.0",
"prettier": "^2.8.8",
"typescript": "^4.9.5"
}
}
63 changes: 63 additions & 0 deletions apps/sanity/schemas/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { defineType, defineField, defineArrayMember } from "sanity";
import { CalendarClock } from "lucide-react";

export default defineType({
name: "event",
title: "Event",
icon: CalendarClock,
type: "document",
fields: [
defineField({
name: "title",
title: "Title",
type: "string",
validation: (Rule) => Rule.required(),
}),
defineField({
name: "location",
title: "Location",
type: "string",
}),
defineField({
name: "virtual",
title: "Virtual Meeting Link",
type: "url",
}),
defineField({
name: "startTime",
title: "Start Time",
type: "datetime",
validation: (Rule) => Rule.required(),
}),
defineField({
name: "endTime",
title: "End Time",
type: "datetime",
validation: (Rule) => Rule.required(),
}),
defineField({
name: "organization",
title: "Organization",
type: "string",
}),
defineField({
name: "hosts",
title: "Hosts",
type: "array",
of: [defineArrayMember({ type: "string" })],
}),
defineField({
name: "description",
title: "Description",
type: "array",
of: [
defineArrayMember({
type: "block",
styles: [{ title: "Normal", value: "normal" }],
lists: [],
}),
],
validation: (Rule) => Rule.required(),
}),
],
});
55 changes: 55 additions & 0 deletions apps/sanity/schemas/faqs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { defineType, defineField, defineArrayMember } from "sanity";
import { toPlainText } from "@portabletext/react";
import { FileQuestion } from "lucide-react";

export default defineType({
name: "faqs",
title: "FAQs",
type: "document",
fields: [
defineField({
name: "faqs",
title: "FAQs",
type: "array",
of: [
defineArrayMember({
type: "object",
name: "faq",
fields: [
defineField({
name: "question",
title: "Question",
type: "text",
}),
defineField({
name: "answer",
title: "Answer",
type: "array",
of: [
defineArrayMember({
type: "block",
styles: [{ title: "Normal", value: "normal" }],
lists: [],
}),
],
}),
],

preview: {
select: {
title: "question",
subtitle: "answer",
},
prepare({ title, subtitle }) {
return {
title,
subtitle: subtitle ? toPlainText(subtitle) : undefined,
media: FileQuestion,
};
},
},
}),
],
}),
],
});
7 changes: 6 additions & 1 deletion apps/sanity/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export const schemaTypes = []
import faqs from "./faqs";
import event from "./event";
import resource from "./resource";
import sponsors from "./sponsors";

export const schemaTypes = [faqs, event, resource, sponsors];
71 changes: 71 additions & 0 deletions apps/sanity/schemas/resource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { defineType, defineField, defineArrayMember } from "sanity";
import { Globe } from "lucide-react";

export default defineType({
name: "resource",
title: "Resources",
type: "document",
icon: Globe,
fields: [
defineField({
name: "title",
title: "Title",
type: "string",
validation: (Rule) => Rule.required(),
}),
defineField({
name: "resourceType",
title: "Resource Type",
type: "string",
options: {
list: [
{ title: "API", value: "api" },
{ title: "Backend", value: "backend" },
{ title: "Frontend", value: "frontend" },
{ title: "Starter Pack", value: "starter-pack" },
],
},
validation: (Rule) => Rule.required(),
}),
defineField({
name: "description",
title: "Description",
type: "array",
of: [
defineArrayMember({
type: "block",
styles: [{ title: "Normal", value: "normal" }],
lists: [],
}),
],
validation: (Rule) => Rule.required(),
}),
defineField({
name: "link",
title: "Link",
type: "url",
validation: (Rule) => Rule.required(),
}),
defineField({
name: "logo",
title: "Logo",
type: "image",
validation: (Rule) => Rule.required(),
}),
defineField({
name: "stickyNoteColor",
title: "Sticky Note Color",
description:
"Note that the color will be used as a background for black text, so please choose a color with enough contrast.",
type: "color",
validation: (Rule) => Rule.required(),
}),
],
preview: {
select: {
title: "title",
subtitle: "description",
media: "logo",
},
},
});
61 changes: 61 additions & 0 deletions apps/sanity/schemas/sponsors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { defineType, defineField, defineArrayMember } from "sanity";
import { HeartHandshake } from "lucide-react";

export default defineType({
name: "sponsors",
title: "Sponsors",
icon: HeartHandshake,
type: "document",
fields: [
defineField({
name: "sponsors",
title: "Sponsors",
type: "array",
of: [
defineArrayMember({
type: "object",
name: "sponsor",
fields: [
defineField({
name: "name",
title: "Name",
type: "string",
validation: (Rule) => Rule.required(),
}),
defineField({
name: "url",
title: "URL",
type: "url",
}),
defineField({
name: "tier",
title: "Tier",
type: "string",
options: {
list: [
{
title: "Bronze",
value: "bronze",
},
{
title: "Silver",
value: "silver",
},
],
layout: "radio",
direction: "vertical",
},
validation: (Rule) => Rule.required(),
}),
defineField({
name: "logo",
title: "Logo",
type: "image",
validation: (Rule) => Rule.required(),
}),
],
}),
],
}),
],
});
Loading

0 comments on commit 3528ad0

Please sign in to comment.