/
index.tsx
58 lines (51 loc) · 1.5 KB
/
index.tsx
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { GetStaticPropsContext, GetStaticPropsResult } from "next"
import Head from "next/head"
import FormattedLink from "../../components/FormattedLink"
import Main from "../../components/Main"
import { getGuides } from "../../utils/data-cache"
import { urlify } from "../../utils/utils"
interface Props {
guides: string[]
}
export default function Guides(props: Props & { location: string }) {
const desc = "Click to find our currently available guides and routes for Genshin Impact."
return (
<Main>
<Head>
<title>Guides | Hu Tao</title>
<meta name="twitter:card" content="summary" />
<meta property="og:title" content="Guides | Hu Tao" />
<meta property="og:description" content={desc} />
<meta property="description" content={desc} />
</Head>
<h1 className="text-5xl font-bold pb-2">
Guides
</h1>
<ul>
{props.guides.map(g => (
<li key={g}>
-{" "}
<FormattedLink className="font-semibold text-xl" location={props.location} href={`/guides/${urlify(g, false)}`} >
{g}
</FormattedLink>
</li>
))}
</ul>
</Main>
)
}
export async function getStaticProps(context: GetStaticPropsContext): Promise<GetStaticPropsResult<Props>> {
const data = await getGuides()
if (!data) {
return {
notFound: true,
revalidate: 15 * 60
}
}
return {
props: {
guides: data.map(g => g.name)
},
revalidate: 60 * 60 * 1
}
}