forked from skillrecordings/egghead-next
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcourse.tsx
More file actions
34 lines (31 loc) · 751 Bytes
/
course.tsx
File metadata and controls
34 lines (31 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as React from 'react'
import useSWR from 'swr'
import {loadCourse} from 'lib/courses'
import Link from 'next/link'
import {FunctionComponent} from 'react'
type CourseWidgetProps = {
slug: string
}
const CourseWidget: FunctionComponent<CourseWidgetProps> = ({slug}) => {
const {data} = useSWR(slug, loadCourse)
return (
<div>
{data && (
<>
<Link href={data.path}>
<a>
<img
alt="illustration"
className="w-64"
src={data.square_cover_480_url}
/>
{data.title}
</a>
</Link>{' '}
by {data.instructor.full_name}
</>
)}
</div>
)
}
export default CourseWidget