1+ "use client"
2+
13import { Fragment , lazy , Suspense } from "react"
2- import type { GetStaticProps , InferGetStaticPropsType } from "next"
34import { FaDiscord , FaGithub } from "react-icons/fa6"
45import { IoMdCopy } from "react-icons/io"
56import { MdCheck } from "react-icons/md"
@@ -8,10 +9,9 @@ import type {
89 AllMetricData ,
910 BasePageProps ,
1011 CommunityBlog ,
11- Lang ,
12- Params ,
1312 RSSItem ,
1413} from "@/lib/types"
14+ import { CommunityEvent } from "@/lib/interfaces"
1515
1616import { ChevronNext } from "@/components/Chevron"
1717import CodeModal from "@/components/CodeModal"
@@ -24,8 +24,13 @@ import Calendar from "@/components/icons/calendar.svg"
2424import CalendarAdd from "@/components/icons/calendar-add.svg"
2525import { Image } from "@/components/Image"
2626import MainArticle from "@/components/MainArticle"
27- import PageMetadata from "@/components/PageMetadata"
2827import { TranslatathonBanner } from "@/components/Translatathon/TranslatathonBanner"
28+ import {
29+ Accordion ,
30+ AccordionContent ,
31+ AccordionItem ,
32+ AccordionTrigger ,
33+ } from "@/components/ui/accordion"
2934import { Button , ButtonLink } from "@/components/ui/buttons/Button"
3035import SvgButtonLink , {
3136 type SvgButtonLinkProps ,
@@ -56,43 +61,13 @@ import {
5661import WindowBox from "@/components/WindowBox"
5762
5863import { cn } from "@/lib/utils/cn"
59- import { dataLoader } from "@/lib/utils/data/dataLoader"
6064import { isValidDate } from "@/lib/utils/date"
61- import { existsNamespace } from "@/lib/utils/existsNamespace"
62- import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
6365import { trackCustomEvent } from "@/lib/utils/matomo"
64- import { polishRSSList } from "@/lib/utils/rss"
6566import { 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"
7967
80- import {
81- Accordion ,
82- AccordionContent ,
83- AccordionItem ,
84- AccordionTrigger ,
85- } from "../../components/ui/accordion"
68+ import { GITHUB_REPO_URL } from "@/lib/constants"
8669
8770import { 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"
9671import EventFallback from "@/public/images/events/event-placeholder.png"
9772import BuildersImage from "@/public/images/heroes/developers-hub-hero.jpg"
9873import ActivityImage from "@/public/images/heroes/layer-2-hub-hero.jpg"
@@ -111,110 +86,17 @@ const Codeblock = lazy(() =>
11186
11287const StatsBoxGrid = lazy ( ( ) => import ( "@/components/StatsBoxGrid" ) )
11388
114- // API calls
115- const fetchXmlBlogFeeds = async ( ) => {
116- return await fetchRSS ( BLOG_FEEDS )
117- }
118-
11989type Props = BasePageProps & {
90+ calendar : CommunityEvent [ ]
12091 metricResults : AllMetricData
12192 rssData : { rssItems : RSSItem [ ] ; blogLinks : CommunityBlog [ ] }
12293}
12394
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-
21395const HomePage = ( {
21496 calendar,
21597 metricResults,
21698 rssData : { rssItems, blogLinks } ,
217- } : InferGetStaticPropsType < typeof getStaticProps > ) => {
99+ } : Props ) => {
218100 const {
219101 t,
220102 locale,
@@ -236,10 +118,6 @@ const HomePage = ({
236118
237119 return (
238120 < 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- />
243121 < TranslatathonBanner />
244122 < HomeHero heroImg = { Hero } className = "w-full" />
245123 < div className = "w-full space-y-32 px-4 md:mx-6 lg:space-y-48" >
@@ -504,7 +382,7 @@ const HomePage = ({
504382 < button
505383 key = { title }
506384 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" ,
508386 isModalOpen &&
509387 idx === activeCode &&
510388 "bg-background-highlight"
0 commit comments