Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sk): adding tips in navigation and updating the thumbnail #3

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/scriptkit/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const IMAGE_HOST_DOMAINS = [
'res.cloudinary.com',
'github.com',
process.env.NEXT_PUBLIC_HOST,
`image.mux.com`,
]

/**
Expand Down
1 change: 1 addition & 0 deletions apps/scriptkit/src/components/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {twMerge} from 'tailwind-merge'

const navItems = [
{name: 'Free Tutorials', href: '/tutorials'},
{name: 'Tips', href: '/tips'},
{name: 'Community Scripts', href: '/scripts'},
{name: 'Docs', href: 'https://github.com/johnlindquist/kit/blob/main/API.md'},
{
Expand Down
3 changes: 3 additions & 0 deletions apps/scriptkit/src/lib/tips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const TipSchema = z.object({
body: z.string().nullable().optional(),
summary: z.any().array().nullable().optional(),
videoResourceId: z.nullable(z.string()).optional(),
muxPlaybackId: z.nullable(z.string()).optional(),
transcript: z.nullable(z.string()).optional(),
tweetId: z.nullable(z.string()).optional(),
})
Expand All @@ -33,6 +34,7 @@ export const getAllTips = async (): Promise<Tip[]> => {
summary,
body,
"videoResourceId": resources[@->._type == 'videoResource'][0]->_id,
"muxPlaybackId": resources[@->._type == 'videoResource'][0]-> muxAsset.muxPlaybackId,
"slug": slug.current,
"transcript": resources[@->._type == 'videoResource'][0]-> castingwords.transcript,
"tweetId": resources[@._type == 'tweet'][0].tweetId
Expand All @@ -53,6 +55,7 @@ export const getTip = async (slug: string): Promise<Tip> => {
summary,
body,
"videoResourceId": resources[@->._type == 'videoResource'][0]->_id,
"muxPlaybackId": resources[@->._type == 'videoResource'][0]-> muxAsset.muxPlaybackId,
"slug": slug.current,
"transcript": resources[@->._type == 'videoResource'][0]-> castingwords.transcript,
"tweetId": resources[@._type == 'tweet'][0].tweetId
Expand Down
6 changes: 3 additions & 3 deletions apps/scriptkit/src/pages/tips/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export default TipsIndex

const TipCard: React.FC<{tip: Tip}> = ({tip}) => {
const {title} = tip
const thumbnail = `${getBaseUrl()}/api/video-thumb?videoResourceId=${
tip?.videoResourceId
}`
const muxPlaybackId = tip?.muxPlaybackId
const thumbnail = `https://image.mux.com/${muxPlaybackId}/thumbnail.png?width=720&height=405&fit_mode=preserve`

const router = useRouter()
const {tipCompleted} = useTipComplete(tip.slug)

Expand Down
Loading