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 VideoGame type, schema and query
- Loading branch information
1 parent
56d8771
commit ffbf797
Showing
10 changed files
with
165 additions
and
39 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
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
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
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,47 @@ | ||
'use client'; | ||
|
||
import Image from 'next/image'; | ||
import * as React from 'react'; | ||
|
||
import { VideoGame } from '@/types/VideoGame'; | ||
|
||
export interface VideoGameProps { | ||
videoGames: VideoGame[]; | ||
} | ||
|
||
const VideoGames = ({ videoGames }: VideoGameProps) => { | ||
return ( | ||
<div className='mb-6'> | ||
<div className='m-2 flex'> | ||
<h2>Games I'm addicted to</h2> | ||
</div> | ||
|
||
<div className='rounded p-3 dark:bg-slate-900'> | ||
<ul className='scroll-mandatory relative -mx-4 flex w-[100vw] snap-x gap-3 overflow-x-auto px-4 pb-6 md:mx-0 md:w-full md:px-0'> | ||
{videoGames.map((game) => ( | ||
<li | ||
key={game._id} | ||
className='h-[180px] w-[136px] shrink-0 snap-center overflow-hidden rounded-lg bg-transparent p-1 transition-all hover:bg-gradient-to-r hover:from-purple-300 hover:to-purple-700' | ||
> | ||
<a | ||
href={game.mediaLink} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
> | ||
<Image | ||
className='rounded-md' | ||
alt={game.title} | ||
src={game.cover} | ||
width={130} | ||
height={130} | ||
/> | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default VideoGames; |
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,10 @@ | ||
import { groq } from 'next-sanity'; | ||
|
||
export const videoGamesQuery = groq` | ||
*[_type == "videoGame"] | order(year desc) { | ||
_id, | ||
title, | ||
year, | ||
"cover": cover.asset->url, | ||
mediaLink, | ||
}`; |
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: 'videoGame', | ||
title: 'Video Game', | ||
type: 'document', | ||
fields: [ | ||
defineField({ | ||
name: 'title', | ||
title: 'Title', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'year', | ||
title: 'Year', | ||
type: 'number', | ||
}), | ||
defineField({ | ||
name: 'cover', | ||
title: 'Cover', | ||
type: 'image', | ||
}), | ||
defineField({ | ||
name: 'mediaLink', | ||
title: 'Media Link', | ||
type: 'string', | ||
}), | ||
], | ||
orderings: [ | ||
{ | ||
title: 'Year', | ||
name: 'yearDesc', | ||
by: [{ field: 'year', direction: 'desc' }], | ||
}, | ||
], | ||
}); |
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,7 @@ | ||
export interface VideoGame { | ||
_id: string; | ||
title: string; | ||
year: number; | ||
cover: string; | ||
mediaLink: string; | ||
} |