From 1e1288602e30d8ac22f0d109382e2649612d4b81 Mon Sep 17 00:00:00 2001 From: "marta.pancaldi" Date: Thu, 6 Jul 2023 23:47:38 +0200 Subject: [PATCH] feat: add simple schema - skill and skillIcon --- sanity/schema.ts | 5 ++- src/{ => pages}/__tests__/pages/404.test.tsx | 0 src/pages/api/hello.ts | 2 +- src/schemas/skill.ts | 35 ++++++++++++++++++++ src/schemas/skillIcon.ts | 19 +++++++++++ src/types/Skill.ts | 8 +++++ src/types/SkillIcon.ts | 4 +++ 7 files changed, 71 insertions(+), 2 deletions(-) rename src/{ => pages}/__tests__/pages/404.test.tsx (100%) create mode 100644 src/schemas/skill.ts create mode 100644 src/schemas/skillIcon.ts create mode 100644 src/types/Skill.ts create mode 100644 src/types/SkillIcon.ts diff --git a/sanity/schema.ts b/sanity/schema.ts index 0b7461f..32410c3 100644 --- a/sanity/schema.ts +++ b/sanity/schema.ts @@ -1,5 +1,8 @@ import { type SchemaTypeDefinition } from 'sanity'; +import skill from '../src/schemas/skill'; +import skillIcon from '../src/schemas/skillIcon'; + export const schema: { types: SchemaTypeDefinition[] } = { - types: [], + types: [skill, skillIcon], }; diff --git a/src/__tests__/pages/404.test.tsx b/src/pages/__tests__/pages/404.test.tsx similarity index 100% rename from src/__tests__/pages/404.test.tsx rename to src/pages/__tests__/pages/404.test.tsx diff --git a/src/pages/api/hello.ts b/src/pages/api/hello.ts index 5a763fd..ac3e359 100644 --- a/src/pages/api/hello.ts +++ b/src/pages/api/hello.ts @@ -3,5 +3,5 @@ import { NextApiRequest, NextApiResponse } from 'next'; export default function hello(req: NextApiRequest, res: NextApiResponse) { - res.status(200).json({ name: 'Bambang' }); + res.status(200).json({ name: 'Marta' }); } diff --git a/src/schemas/skill.ts b/src/schemas/skill.ts new file mode 100644 index 0000000..4b24415 --- /dev/null +++ b/src/schemas/skill.ts @@ -0,0 +1,35 @@ +import { defineField, defineType } from 'sanity'; + +export default defineType({ + name: 'skill', + title: 'Skill', + type: 'document', + fields: [ + defineField({ + name: 'name', + title: 'Name', + type: 'string', + }), + defineField({ + name: 'title', + title: 'Title', + type: 'string', + }), + defineField({ + name: 'description', + title: 'Description', + type: 'string', + }), + defineField({ + name: 'icons', + title: 'Icons', + type: 'array', + of: [ + { + type: 'reference', + to: [{ type: 'skillIcon' }], + }, + ], + }), + ], +}); diff --git a/src/schemas/skillIcon.ts b/src/schemas/skillIcon.ts new file mode 100644 index 0000000..5c50549 --- /dev/null +++ b/src/schemas/skillIcon.ts @@ -0,0 +1,19 @@ +import { defineField, defineType } from 'sanity'; + +export default defineType({ + name: 'skillIcon', + title: 'SkillIcon', + type: 'document', + fields: [ + defineField({ + name: 'title', + title: 'Title', + type: 'string', + }), + defineField({ + name: 'url', + title: 'Url', + type: 'string', + }), + ], +}); diff --git a/src/types/Skill.ts b/src/types/Skill.ts new file mode 100644 index 0000000..3b23bc7 --- /dev/null +++ b/src/types/Skill.ts @@ -0,0 +1,8 @@ +import { SkillIcon } from '@/types/SkillIcon'; + +export interface Skill { + name: string; + title: string; + description: string; + icons: SkillIcon[]; +} diff --git a/src/types/SkillIcon.ts b/src/types/SkillIcon.ts new file mode 100644 index 0000000..5469c2f --- /dev/null +++ b/src/types/SkillIcon.ts @@ -0,0 +1,4 @@ +export interface SkillIcon { + title: string; + url: string; +}