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 TvSeries type, schema and query
- Loading branch information
1 parent
ffbf797
commit 5b716f6
Showing
8 changed files
with
117 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
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 { TvShow } from '@/types/TvSeries'; | ||
|
||
export interface TvSeriesProps { | ||
tvSeries: TvShow[]; | ||
} | ||
|
||
const TvSeries = ({ tvSeries }: TvSeriesProps) => { | ||
return ( | ||
<div className='mb-6'> | ||
<div className='m-2 flex'> | ||
<h2>Favourite TV Series</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'> | ||
{tvSeries.map((tvSeries) => ( | ||
<li | ||
key={tvSeries._id} | ||
className='h-[200px] w-[136px] shrink-0 snap-center overflow-hidden rounded-lg bg-transparent p-1 transition-all hover:bg-gradient-to-r hover:from-yellow-300 hover:to-yellow-700' | ||
> | ||
<a | ||
href={tvSeries.mediaLink} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
> | ||
<Image | ||
className='rounded-md' | ||
alt={tvSeries.title} | ||
src={tvSeries.poster} | ||
width={130} | ||
height={130} | ||
/> | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TvSeries; |
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 tvSeriesQuery = groq` | ||
*[_type == "tvSeries"] | order(year desc) { | ||
_id, | ||
title, | ||
year, | ||
"poster": poster.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: 'tvSeries', | ||
title: 'TV Series', | ||
type: 'document', | ||
fields: [ | ||
defineField({ | ||
name: 'title', | ||
title: 'Title', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'year', | ||
title: 'Year', | ||
type: 'number', | ||
}), | ||
defineField({ | ||
name: 'poster', | ||
title: 'Poster', | ||
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 TvShow { | ||
_id: string; | ||
title: string; | ||
year: number; | ||
poster: string; | ||
mediaLink: string; | ||
} |