generated from theodorusclarence/ts-nextjs-tailwind-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add language type, schema and query
- Loading branch information
1 parent
f2b01f9
commit 81223c5
Showing
6 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { type SchemaTypeDefinition } from 'sanity'; | ||
|
||
import job from '../src/schemas/job'; | ||
import language from '../src/schemas/language'; | ||
import school from '../src/schemas/school'; | ||
import shortText from '../src/schemas/shortText'; | ||
import skill from '../src/schemas/skill'; | ||
import skillIcon from '../src/schemas/skillIcon'; | ||
|
||
export const schema: { types: SchemaTypeDefinition[] } = { | ||
types: [job, school, shortText, skill, skillIcon], | ||
types: [job, language, school, shortText, skill, skillIcon], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use client'; | ||
|
||
import Image from 'next/image'; | ||
import * as React from 'react'; | ||
|
||
import { Language } from '@/types/Language'; | ||
|
||
export interface LanguageProps { | ||
languages: Language[]; | ||
} | ||
|
||
const Languages = ({ languages }: LanguageProps) => { | ||
return ( | ||
<div> | ||
<div className='m-2 flex'> | ||
<h2>Languages</h2> | ||
</div> | ||
|
||
<div className='flex flex-col md:w-full md:flex-row md:justify-between'> | ||
{languages.map((language) => ( | ||
<div | ||
key={language.id} | ||
className='mb-4 flex flex-row items-center rounded-md p-4 shadow-md dark:bg-slate-900 md:w-64' | ||
> | ||
<Image | ||
src={language.flagUrl} | ||
alt={language.name} | ||
width={40} | ||
height={40} | ||
/> | ||
|
||
<span className='ms-4 font-semibold'>{language.level}</span> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Languages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { groq } from 'next-sanity'; | ||
|
||
export const languageQuery = groq` | ||
*[_type == "language"] | order(id asc) { | ||
_id, | ||
name, | ||
level, | ||
"flagUrl": flag.asset->url | ||
}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { defineField, defineType } from 'sanity'; | ||
|
||
export default defineType({ | ||
name: 'language', | ||
title: 'Language', | ||
type: 'document', | ||
fields: [ | ||
defineField({ | ||
name: 'id', | ||
title: 'Id', | ||
type: 'number', | ||
}), | ||
defineField({ | ||
name: 'name', | ||
title: 'Name', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'level', | ||
title: 'Level', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'flag', | ||
title: 'Icons', | ||
type: 'image', | ||
}), | ||
], | ||
orderings: [ | ||
{ | ||
title: 'Custom Order', | ||
name: 'custom', | ||
by: [{ field: 'id', direction: 'asc' }], | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface Language { | ||
id: number; | ||
name: string; | ||
level: string; | ||
flagUrl: string; | ||
} |