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 Podcast type, schema and query
- Loading branch information
1 parent
da76c4e
commit 56d8771
Showing
8 changed files
with
127 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,44 @@ | ||
'use client'; | ||
|
||
import Image from 'next/image'; | ||
import * as React from 'react'; | ||
|
||
import { Podcast } from '@/types/Podcast'; | ||
|
||
export interface PodcastProps { | ||
podcasts: Podcast[]; | ||
} | ||
|
||
const Podcasts = ({ podcasts }: PodcastProps) => { | ||
return ( | ||
<div className=''> | ||
<div className='m-2 flex'> | ||
<h2>Podcasts I follow</h2> | ||
</div> | ||
|
||
<ul className='scroll-mandatory relative -mx-4 flex w-[100vw] snap-x gap-3 overflow-x-auto px-4 pb-14 md:mx-0 md:w-full md:px-0'> | ||
{podcasts.map((podcast) => ( | ||
<li | ||
key={podcast._id} | ||
className='h-[136px] w-[136px] shrink-0 snap-center overflow-hidden rounded-lg bg-transparent p-1 transition-all hover:bg-gradient-to-r hover:from-orange-400 hover:to-orange-700' | ||
> | ||
<a | ||
href={podcast.mediaLink} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
> | ||
<Image | ||
alt={podcast.name} | ||
src={podcast.cover} | ||
width={130} | ||
height={130} | ||
/> | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Podcasts; |
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,11 @@ | ||
import { groq } from 'next-sanity'; | ||
|
||
export const podcastsQuery = groq` | ||
*[_type == "podcast"] | order(author asc) { | ||
_id, | ||
name, | ||
author, | ||
language, | ||
"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,47 @@ | ||
import { defineField, defineType } from 'sanity'; | ||
|
||
export default defineType({ | ||
name: 'podcast', | ||
title: 'Podcast', | ||
type: 'document', | ||
fields: [ | ||
defineField({ | ||
name: 'name', | ||
title: 'Name', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'author', | ||
title: 'Author', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'language', | ||
title: 'language', | ||
type: 'string', | ||
options: { | ||
list: [ | ||
{ title: 'En', value: 'en' }, | ||
{ title: 'It', value: 'it' }, | ||
], | ||
}, | ||
}), | ||
defineField({ | ||
name: 'cover', | ||
title: 'Cover', | ||
type: 'image', | ||
}), | ||
defineField({ | ||
name: 'mediaLink', | ||
title: 'Media Link', | ||
type: 'string', | ||
}), | ||
], | ||
orderings: [ | ||
{ | ||
title: 'Author', | ||
name: 'authorAsc', | ||
by: [{ field: 'author', 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,8 @@ | ||
export interface Podcast { | ||
_id: string; | ||
name: string; | ||
author: string; | ||
language: string; | ||
cover: string; | ||
mediaLink: string; | ||
} |