Skip to content

Commit

Permalink
feat: add simple schema - skill and skillIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc-resourcify committed Jul 6, 2023
1 parent 9fd8c25 commit 1e12886
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sanity/schema.ts
Original file line number Diff line number Diff line change
@@ -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],
};
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/api/hello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
}
35 changes: 35 additions & 0 deletions src/schemas/skill.ts
Original file line number Diff line number Diff line change
@@ -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' }],
},
],
}),
],
});
19 changes: 19 additions & 0 deletions src/schemas/skillIcon.ts
Original file line number Diff line number Diff line change
@@ -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',
}),
],
});
8 changes: 8 additions & 0 deletions src/types/Skill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SkillIcon } from '@/types/SkillIcon';

export interface Skill {
name: string;
title: string;
description: string;
icons: SkillIcon[];
}
4 changes: 4 additions & 0 deletions src/types/SkillIcon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface SkillIcon {
title: string;
url: string;
}

0 comments on commit 1e12886

Please sign in to comment.