1
+ "use client"
2
+
1
3
import { Fragment , lazy , Suspense } from "react"
2
- import type { GetStaticProps , InferGetStaticPropsType } from "next"
3
4
import { FaDiscord , FaGithub } from "react-icons/fa6"
4
5
import { IoMdCopy } from "react-icons/io"
5
6
import { MdCheck } from "react-icons/md"
@@ -8,10 +9,9 @@ import type {
8
9
AllMetricData ,
9
10
BasePageProps ,
10
11
CommunityBlog ,
11
- Lang ,
12
- Params ,
13
12
RSSItem ,
14
13
} from "@/lib/types"
14
+ import { CommunityEvent } from "@/lib/interfaces"
15
15
16
16
import { ChevronNext } from "@/components/Chevron"
17
17
import CodeModal from "@/components/CodeModal"
@@ -24,8 +24,13 @@ import Calendar from "@/components/icons/calendar.svg"
24
24
import CalendarAdd from "@/components/icons/calendar-add.svg"
25
25
import { Image } from "@/components/Image"
26
26
import MainArticle from "@/components/MainArticle"
27
- import PageMetadata from "@/components/PageMetadata"
28
27
import { TranslatathonBanner } from "@/components/Translatathon/TranslatathonBanner"
28
+ import {
29
+ Accordion ,
30
+ AccordionContent ,
31
+ AccordionItem ,
32
+ AccordionTrigger ,
33
+ } from "@/components/ui/accordion"
29
34
import { Button , ButtonLink } from "@/components/ui/buttons/Button"
30
35
import SvgButtonLink , {
31
36
type SvgButtonLinkProps ,
@@ -56,43 +61,13 @@ import {
56
61
import WindowBox from "@/components/WindowBox"
57
62
58
63
import { cn } from "@/lib/utils/cn"
59
- import { dataLoader } from "@/lib/utils/data/dataLoader"
60
64
import { isValidDate } from "@/lib/utils/date"
61
- import { existsNamespace } from "@/lib/utils/existsNamespace"
62
- import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
63
65
import { trackCustomEvent } from "@/lib/utils/matomo"
64
- import { polishRSSList } from "@/lib/utils/rss"
65
66
import { breakpointAsNumber } from "@/lib/utils/screen"
66
- import { getLocaleTimestamp } from "@/lib/utils/time"
67
- import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
68
-
69
- import {
70
- BASE_TIME_UNIT ,
71
- BLOG_FEEDS ,
72
- BLOGS_WITHOUT_FEED ,
73
- CALENDAR_DISPLAY_COUNT ,
74
- DEFAULT_LOCALE ,
75
- GITHUB_REPO_URL ,
76
- LOCALES_CODES ,
77
- RSS_DISPLAY_COUNT ,
78
- } from "@/lib/constants"
79
67
80
- import {
81
- Accordion ,
82
- AccordionContent ,
83
- AccordionItem ,
84
- AccordionTrigger ,
85
- } from "../../components/ui/accordion"
68
+ import { GITHUB_REPO_URL } from "@/lib/constants"
86
69
87
70
import { useClipboard } from "@/hooks/useClipboard"
88
- import loadNamespaces from "@/i18n/loadNamespaces"
89
- import { fetchCommunityEvents } from "@/lib/api/calendarEvents"
90
- import { fetchEthPrice } from "@/lib/api/fetchEthPrice"
91
- import { fetchGrowThePie } from "@/lib/api/fetchGrowThePie"
92
- import { fetchAttestantPosts } from "@/lib/api/fetchPosts"
93
- import { fetchRSS } from "@/lib/api/fetchRSS"
94
- import { fetchTotalEthStaked } from "@/lib/api/fetchTotalEthStaked"
95
- import { fetchTotalValueLocked } from "@/lib/api/fetchTotalValueLocked"
96
71
import EventFallback from "@/public/images/events/event-placeholder.png"
97
72
import BuildersImage from "@/public/images/heroes/developers-hub-hero.jpg"
98
73
import ActivityImage from "@/public/images/heroes/layer-2-hub-hero.jpg"
@@ -111,110 +86,17 @@ const Codeblock = lazy(() =>
111
86
112
87
const StatsBoxGrid = lazy ( ( ) => import ( "@/components/StatsBoxGrid" ) )
113
88
114
- // API calls
115
- const fetchXmlBlogFeeds = async ( ) => {
116
- return await fetchRSS ( BLOG_FEEDS )
117
- }
118
-
119
89
type Props = BasePageProps & {
90
+ calendar : CommunityEvent [ ]
120
91
metricResults : AllMetricData
121
92
rssData : { rssItems : RSSItem [ ] ; blogLinks : CommunityBlog [ ] }
122
93
}
123
94
124
- // In seconds
125
- const REVALIDATE_TIME = BASE_TIME_UNIT * 1
126
-
127
- const loadData = dataLoader (
128
- [
129
- [ "ethPrice" , fetchEthPrice ] ,
130
- [ "totalEthStaked" , fetchTotalEthStaked ] ,
131
- [ "totalValueLocked" , fetchTotalValueLocked ] ,
132
- [ "growThePieData" , fetchGrowThePie ] ,
133
- [ "communityEvents" , fetchCommunityEvents ] ,
134
- [ "attestantPosts" , fetchAttestantPosts ] ,
135
- [ "rssData" , fetchXmlBlogFeeds ] ,
136
- ] ,
137
- REVALIDATE_TIME * 1000
138
- )
139
-
140
- export async function getStaticPaths ( ) {
141
- return {
142
- paths : LOCALES_CODES . map ( ( locale ) => ( { params : { locale } } ) ) ,
143
- fallback : false ,
144
- }
145
- }
146
-
147
- export const getStaticProps = ( async ( { params } ) => {
148
- const { locale = DEFAULT_LOCALE } = params || { }
149
-
150
- const [
151
- ethPrice ,
152
- totalEthStaked ,
153
- totalValueLocked ,
154
- growThePieData ,
155
- communityEvents ,
156
- attestantPosts ,
157
- xmlBlogs ,
158
- ] = await loadData ( )
159
-
160
- const metricResults : AllMetricData = {
161
- ethPrice,
162
- totalEthStaked,
163
- totalValueLocked,
164
- txCount : growThePieData . txCount ,
165
- txCostsMedianUsd : growThePieData . txCostsMedianUsd ,
166
- }
167
-
168
- const calendar = communityEvents . upcomingEventData
169
- . sort ( ( a , b ) => {
170
- const dateA = isValidDate ( a . date ) ? new Date ( a . date ) . getTime ( ) : - Infinity
171
- const dateB = isValidDate ( b . date ) ? new Date ( b . date ) . getTime ( ) : - Infinity
172
- return dateA - dateB
173
- } )
174
- . slice ( 0 , CALENDAR_DISPLAY_COUNT )
175
-
176
- // load i18n required namespaces for the given page
177
- const requiredNamespaces = getRequiredNamespacesForPage ( "/" )
178
-
179
- // check if the translated page content file exists for locale
180
- const contentNotTranslated = ! existsNamespace ( locale ! , requiredNamespaces [ 0 ] )
181
-
182
- // load last deploy date to pass to Footer in RootLayout
183
- const lastDeployDate = getLastDeployDate ( )
184
- const lastDeployLocaleTimestamp = getLocaleTimestamp (
185
- locale as Lang ,
186
- lastDeployDate
187
- )
188
-
189
- // RSS feed items
190
- const polishedRssItems = polishRSSList ( attestantPosts , ...xmlBlogs )
191
- const rssItems = polishedRssItems . slice ( 0 , RSS_DISPLAY_COUNT )
192
-
193
- const blogLinks = polishedRssItems . map ( ( { source, sourceUrl } ) => ( {
194
- name : source ,
195
- href : sourceUrl ,
196
- } ) ) as CommunityBlog [ ]
197
- blogLinks . push ( ...BLOGS_WITHOUT_FEED )
198
-
199
- const messages = await loadNamespaces ( locale , requiredNamespaces )
200
-
201
- return {
202
- props : {
203
- messages,
204
- calendar,
205
- contentNotTranslated,
206
- lastDeployLocaleTimestamp,
207
- metricResults,
208
- rssData : { rssItems, blogLinks } ,
209
- } ,
210
- }
211
- } ) satisfies GetStaticProps < Props , Params >
212
-
213
95
const HomePage = ( {
214
96
calendar,
215
97
metricResults,
216
98
rssData : { rssItems, blogLinks } ,
217
- } : InferGetStaticPropsType < typeof getStaticProps > ) => {
99
+ } : Props ) => {
218
100
const {
219
101
t,
220
102
locale,
@@ -236,10 +118,6 @@ const HomePage = ({
236
118
237
119
return (
238
120
< MainArticle className = "flex w-full flex-col items-center" dir = { dir } >
239
- < PageMetadata
240
- title = { t ( "page-index:page-index-meta-title" ) }
241
- description = { t ( "page-index:page-index-meta-description" ) }
242
- />
243
121
< TranslatathonBanner />
244
122
< HomeHero heroImg = { Hero } className = "w-full" />
245
123
< div className = "w-full space-y-32 px-4 md:mx-6 lg:space-y-48" >
@@ -504,7 +382,7 @@ const HomePage = ({
504
382
< button
505
383
key = { title }
506
384
className = { cn (
507
- "flex flex-col gap-y-0.5 border-t px-6 py-4 text-start hover:bg-background-highlight max-md:hidden" ,
385
+ "flex flex-col gap-y-0.5 border-t px-6 py-4 hover:bg-background-highlight max-md:hidden" ,
508
386
isModalOpen &&
509
387
idx === activeCode &&
510
388
"bg-background-highlight"
0 commit comments