Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

index.tsx 5.4 KB

You have to be logged in to leave a comment. Sign In
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  1. import { GetServerSideProps } from 'next'
  2. import {
  3. MainContextT,
  4. MainContext,
  5. getMainContextFromRequest,
  6. useMainContext,
  7. } from 'components/context/MainContext'
  8. import { DefaultLayout } from 'components/DefaultLayout'
  9. import { useTranslation } from 'components/hooks/useTranslation'
  10. import { useVersion } from 'components/hooks/useVersion'
  11. import { LinkExternalIcon } from '@primer/octicons-react'
  12. import { useRouter } from 'next/router'
  13. import { OctocatHeader } from 'components/landing/OctocatHeader'
  14. import { ArticleList } from 'components/landing/FeaturedArticles'
  15. import { Search } from 'components/Search'
  16. type FeaturedLink = {
  17. href: string
  18. title: string
  19. intro: string
  20. }
  21. type Props = {
  22. mainContext: MainContextT
  23. popularLinks: Array<FeaturedLink>
  24. gettingStartedLinks: Array<FeaturedLink>
  25. }
  26. export default function MainLanding({ mainContext, gettingStartedLinks, popularLinks }: Props) {
  27. return (
  28. <MainContext.Provider value={mainContext}>
  29. <DefaultLayout>
  30. <LandingPage gettingStartedLinks={gettingStartedLinks} popularLinks={popularLinks} />
  31. </DefaultLayout>
  32. </MainContext.Provider>
  33. )
  34. }
  35. type LandingPageProps = {
  36. popularLinks: Array<FeaturedLink>
  37. gettingStartedLinks: Array<FeaturedLink>
  38. }
  39. function LandingPage(props: LandingPageProps) {
  40. const router = useRouter()
  41. const { gettingStartedLinks, popularLinks } = props
  42. const { activeProducts, isHomepageVersion } = useMainContext()
  43. const { currentVersion } = useVersion()
  44. const { t } = useTranslation(['homepage', 'search', 'toc'])
  45. return (
  46. <div>
  47. {/* <!-- Hero --> */}
  48. <section id="landing" className="color-bg-tertiary">
  49. <Search isStandalone={true}>
  50. {({ SearchInput, SearchResults }) => {
  51. return (
  52. <div className="container-xl px-3 px-md-6 pb-6 pb-lg-9">
  53. <div className="gutter gutter-xl-spacious pt-6 pt-lg-0 d-lg-flex flex-row-reverse flex-items-center">
  54. <div className="col-lg-7">
  55. <OctocatHeader />
  56. </div>
  57. <div className="col-lg-5 mt-6">
  58. <h1 className="h1-mktg mb-3">{t('search:need_help')}</h1>
  59. {SearchInput}
  60. </div>
  61. </div>
  62. <div className="mt-3">{SearchResults}</div>
  63. </div>
  64. )
  65. }}
  66. </Search>
  67. </section>
  68. {/* <!-- Explore by product --> */}
  69. <section className="container-xl pb-lg-4 my-8 px-3 px-md-6">
  70. <div className="">
  71. <h2 className="text-mono f5 text-normal color-text-secondary text-md-center mb-4">
  72. {t('explore_by_product')}
  73. </h2>
  74. <div className="d-flex flex-wrap gutter gutter-xl-spacious">
  75. {activeProducts.map((product) => {
  76. if (!product.versions?.includes(currentVersion) && !isHomepageVersion) {
  77. return null
  78. }
  79. const href = `${!product.external ? `/${router.locale}` : ''}${
  80. product.versions?.includes(currentVersion)
  81. ? `/${currentVersion}/${product.id}`
  82. : product.href
  83. }`
  84. return (
  85. <div className="d-flex flex-column col-12 col-sm-6 col-lg-3 pb-4" key={product.id}>
  86. <a
  87. className="btn-mktg flex-auto d-flex flex-items-center btn-outline-mktg btn-large-mktg ws-normal "
  88. href={href}
  89. target={product.external ? '_blank' : undefined}
  90. >
  91. {product.name}
  92. {product.external && (
  93. <span className="ml-1">
  94. <LinkExternalIcon />
  95. </span>
  96. )}
  97. </a>
  98. </div>
  99. )
  100. })}
  101. </div>
  102. </div>
  103. </section>
  104. <div className="px-3 px-md-6 container-xl">
  105. <div className="featured-links container-xl">
  106. <div className="gutter gutter-xl-spacious clearfix">
  107. {/* <!-- Getting Started articles --> */}
  108. <div className="col-12 col-lg-6 float-left">
  109. <div className="featured-links-heading pb-4">
  110. <h3 className="f5 text-normal text-mono underline-dashed color-text-secondary">
  111. {t('toc:getting_started')}
  112. </h3>
  113. </div>
  114. <ArticleList maxLines={6} articles={gettingStartedLinks} />
  115. </div>
  116. {/* <!-- Popular articles --> */}
  117. <div className="col-12 col-lg-6 float-left">
  118. <div className="featured-links-heading pb-4">
  119. <h3 className="f5 text-normal text-mono underline-dashed color-text-secondary">
  120. {t('toc:popular')}
  121. </h3>
  122. </div>
  123. <ArticleList maxLines={6} articles={popularLinks} />
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. )
  130. }
  131. export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
  132. const req = context.req as any
  133. return {
  134. props: {
  135. mainContext: getMainContextFromRequest(req),
  136. gettingStartedLinks: req.context.featuredLinks.gettingStarted.map(
  137. ({ title, href, intro }: any) => ({ title, href, intro })
  138. ),
  139. popularLinks: req.context.featuredLinks.popular.map(({ title, href, intro }: any) => ({
  140. title,
  141. href,
  142. intro,
  143. })),
  144. },
  145. }
  146. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...