16838d5dd4
## Changelog - Updated deps - Migrated to Typescript - Replaced `div` with `Fragment` ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
26 lines
621 B
TypeScript
26 lines
621 B
TypeScript
import Link from 'next/link'
|
|
import type { InferGetStaticPropsType } from 'next'
|
|
import type { Repository } from '../types/github'
|
|
|
|
export async function getStaticProps() {
|
|
const res = await fetch('https://api.github.com/repos/preactjs/preact')
|
|
const json: Repository = await res.json()
|
|
return {
|
|
props: {
|
|
stars: json.stargazers_count,
|
|
},
|
|
}
|
|
}
|
|
|
|
export default function PreactStarsPage({
|
|
stars,
|
|
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
return (
|
|
<>
|
|
<p>Preact has {stars} ⭐</p>
|
|
<Link href="/">
|
|
<a>I bet Next.js has more stars (?)</a>
|
|
</Link>
|
|
</>
|
|
)
|
|
}
|