Skip to content

Commit aaced80

Browse files
committed
migrate start page
1 parent 375ca79 commit aaced80

File tree

2 files changed

+55
-55
lines changed

2 files changed

+55
-55
lines changed

src/pages/[locale]/start/index.tsx renamed to app/[locale]/start/_components/start.tsx

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1-
import { GetStaticProps } from "next"
1+
"use client"
2+
23
import dynamic from "next/dynamic"
34
import { useLocale } from "next-intl"
45
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
56

6-
import { BasePageProps, Lang, Wallet } from "@/lib/types"
7+
import { Wallet } from "@/lib/types"
78

89
import { Image } from "@/components/Image"
910
import MainArticle from "@/components/MainArticle"
10-
import PageMetadata from "@/components/PageMetadata"
1111
import StartWithEthereumFlow from "@/components/StartWithEthereumFlow"
1212
import ShareModal from "@/components/StartWithEthereumFlow/ShareModal"
1313

14-
import { existsNamespace } from "@/lib/utils/existsNamespace"
15-
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
16-
import { getLocaleTimestamp } from "@/lib/utils/time"
17-
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
18-
import { getNewToCryptoWallets } from "@/lib/utils/wallets"
19-
20-
import { DEFAULT_LOCALE, LOCALES_CODES } from "@/lib/constants"
21-
22-
import loadNamespaces from "@/i18n/loadNamespaces"
2314
import HeroImage from "@/public/images/heroes/developers-hub-hero.jpg"
2415
import ManDogeImage from "@/public/images/start-with-ethereum/man-doge-playing.png"
2516

@@ -30,43 +21,6 @@ const WalletProviders = dynamic(() => import("@/components/WalletProviders"), {
3021

3122
const queryClient = new QueryClient()
3223

33-
export async function getStaticPaths() {
34-
return {
35-
paths: LOCALES_CODES.map((locale) => ({ params: { locale } })),
36-
fallback: false,
37-
}
38-
}
39-
40-
export const getStaticProps = (async ({ params }) => {
41-
const { locale = DEFAULT_LOCALE } = params || {}
42-
43-
const lastDeployDate = getLastDeployDate()
44-
const lastDeployLocaleTimestamp = getLocaleTimestamp(
45-
locale as Lang,
46-
lastDeployDate
47-
)
48-
49-
const requiredNamespaces = getRequiredNamespacesForPage("/start")
50-
51-
const contentNotTranslated = !existsNamespace(
52-
locale! as string,
53-
requiredNamespaces[2]
54-
)
55-
56-
const messages = await loadNamespaces(locale as string, requiredNamespaces)
57-
58-
const newToCryptoWallets = getNewToCryptoWallets()
59-
60-
return {
61-
props: {
62-
messages,
63-
contentNotTranslated,
64-
lastDeployLocaleTimestamp,
65-
newToCryptoWallets,
66-
},
67-
}
68-
}) satisfies GetStaticProps<BasePageProps>
69-
7024
const StartWithCryptoPage = ({
7125
newToCryptoWallets,
7226
}: {
@@ -78,12 +32,6 @@ const StartWithCryptoPage = ({
7832
<QueryClientProvider client={queryClient}>
7933
<WalletProviders locale={locale}>
8034
<MainArticle className="flex w-full flex-col items-center overflow-x-hidden">
81-
<PageMetadata
82-
title={"Start with crypto"}
83-
description={"Your gateway to the world of ethereum"}
84-
image={HeroImage.src}
85-
/>
86-
8735
<div className="mb-16 h-[240px] w-full md:h-[380px] lg:h-[398px]">
8836
<Image
8937
src={HeroImage}

app/[locale]/start/page.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import pick from "lodash.pick"
2+
3+
import { Lang } from "@/lib/types"
4+
5+
import I18nProvider from "@/components/I18nProvider"
6+
7+
import { getMetadata } from "@/lib/utils/metadata"
8+
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
9+
import { getNewToCryptoWallets } from "@/lib/utils/wallets"
10+
11+
import StartPage from "./_components/start"
12+
13+
import { loadMessages } from "@/i18n/loadMessages"
14+
15+
const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
16+
const { locale } = await params
17+
18+
// Get i18n messages
19+
const allMessages = await loadMessages(locale)
20+
const requiredNamespaces = getRequiredNamespacesForPage("/start")
21+
const messages = pick(allMessages, requiredNamespaces)
22+
23+
const newToCryptoWallets = getNewToCryptoWallets()
24+
const wallets = newToCryptoWallets.map((wallet) => ({
25+
...wallet,
26+
supportedLanguages: [],
27+
}))
28+
29+
return (
30+
<I18nProvider locale={locale} messages={messages}>
31+
<StartPage newToCryptoWallets={wallets} />
32+
</I18nProvider>
33+
)
34+
}
35+
36+
export async function generateMetadata({
37+
params,
38+
}: {
39+
params: Promise<{ locale: string }>
40+
}) {
41+
const { locale } = await params
42+
43+
return await getMetadata({
44+
locale,
45+
slug: ["start"],
46+
title: "Start with crypto",
47+
description: "Your gateway to the world of ethereum",
48+
image: "/images/heroes/developers-hub-hero.jpg",
49+
})
50+
}
51+
52+
export default Page

0 commit comments

Comments
 (0)