forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
93 lines (83 loc) · 2.69 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from 'react'
import type { GetServerSideProps } from 'next'
import { MainContextT, MainContext, getMainContext } from 'components/context/MainContext'
import { DefaultLayout } from 'components/DefaultLayout'
import { useTranslation } from 'components/hooks/useTranslation'
import { ArticleList } from 'components/landing/ArticleList'
import { HomePageHero } from 'components/homepage/HomePageHero'
import type { ProductGroupT } from 'components/homepage/ProductSelections'
import { ProductSelections } from 'components/homepage/ProductSelections'
type FeaturedLink = {
href: string
title: string
intro: string
}
type Props = {
mainContext: MainContextT
popularLinks: Array<FeaturedLink>
gettingStartedLinks: Array<FeaturedLink>
productGroups: Array<ProductGroupT>
}
export default function MainHomePage({
mainContext,
gettingStartedLinks,
popularLinks,
productGroups,
}: Props) {
return (
<MainContext.Provider value={mainContext}>
<DefaultLayout>
<HomePage
gettingStartedLinks={gettingStartedLinks}
popularLinks={popularLinks}
productGroups={productGroups}
/>
</DefaultLayout>
</MainContext.Provider>
)
}
type HomePageProps = {
popularLinks: Array<FeaturedLink>
gettingStartedLinks: Array<FeaturedLink>
productGroups: Array<ProductGroupT>
}
function HomePage(props: HomePageProps) {
const { gettingStartedLinks, popularLinks, productGroups } = props
const { t } = useTranslation(['toc'])
return (
<div>
<HomePageHero />
<ProductSelections productGroups={productGroups} />
<div className="mt-6 px-3 px-md-6 container-xl">
<div className="container-xl">
<div className="gutter gutter-xl-spacious clearfix">
<div className="col-12 col-lg-6 mb-md-4 mb-lg-0 float-left">
<ArticleList title={t('toc:getting_started')} articles={gettingStartedLinks} />
</div>
<div className="col-12 col-lg-6 float-left">
<ArticleList title={t('toc:popular')} articles={popularLinks} />
</div>
</div>
</div>
</div>
</div>
)
}
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
const req = context.req as any
const res = context.res as any
return {
props: {
mainContext: await getMainContext(req, res),
productGroups: req.context.productGroups,
gettingStartedLinks: req.context.featuredLinks.gettingStarted.map(
({ title, href, intro }: any) => ({ title, href, intro })
),
popularLinks: req.context.featuredLinks.popular.map(({ title, href, intro }: any) => ({
title,
href,
intro,
})),
},
}
}