Skip to content

Commit 0868763

Browse files
authored
Merge pull request #15640 from ethereum/fix-start-ssr
refactor: /start page to server component, extract intl strings
2 parents 06dc866 + 23ec4dc commit 0868763

File tree

5 files changed

+169
-175
lines changed

5 files changed

+169
-175
lines changed

app/[locale]/start/_components/start.tsx

Lines changed: 0 additions & 83 deletions
This file was deleted.

app/[locale]/start/page.tsx

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
import { pick } from "lodash"
2-
import { getMessages, setRequestLocale } from "next-intl/server"
1+
import { getTranslations, setRequestLocale } from "next-intl/server"
32

43
import { Lang } from "@/lib/types"
54

6-
import I18nProvider from "@/components/I18nProvider"
5+
import { Image } from "@/components/Image"
6+
import MainArticle from "@/components/MainArticle"
7+
import StartWithEthereumFlow from "@/components/StartWithEthereumFlow"
8+
import ShareModal from "@/components/StartWithEthereumFlow/ShareModal"
79

810
import { getMetadata } from "@/lib/utils/metadata"
9-
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
1011
import { getNewToCryptoWallets } from "@/lib/utils/wallets"
1112

12-
import StartPage from "./_components/start"
13+
import HeroImage from "@/public/images/heroes/developers-hub-hero.jpg"
14+
import ManDogeImage from "@/public/images/start-with-ethereum/man-doge-playing.png"
1315

1416
const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
1517
const { locale } = await params
1618

1719
setRequestLocale(locale)
1820

19-
// Get i18n messages
20-
const allMessages = await getMessages({ locale })
21-
const requiredNamespaces = getRequiredNamespacesForPage("/start")
22-
const messages = pick(allMessages, requiredNamespaces)
21+
const t = await getTranslations({ locale, namespace: "page-start" })
2322

2423
const newToCryptoWallets = getNewToCryptoWallets()
2524
const wallets = newToCryptoWallets.map((wallet) => ({
@@ -28,9 +27,41 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
2827
}))
2928

3029
return (
31-
<I18nProvider locale={locale} messages={messages}>
32-
<StartPage newToCryptoWallets={wallets} />
33-
</I18nProvider>
30+
<MainArticle className="flex w-full flex-col items-center overflow-x-hidden">
31+
<div className="mb-16 h-[240px] w-full md:h-[380px] lg:h-[398px]">
32+
<Image
33+
src={HeroImage}
34+
alt={t("page-start-hero-alt")}
35+
sizes="(max-width: 1504px) 100vw, 1504px"
36+
className="h-full w-full object-cover"
37+
priority
38+
/>
39+
</div>
40+
41+
<div className="mb-36 flex flex-col gap-12 overflow-x-hidden px-8">
42+
<div className="mx-auto flex max-w-[1000px] flex-col items-center gap-4 text-center">
43+
<h1>{t("page-start-title")}</h1>
44+
<p>{t("page-start-subtitle")}</p>
45+
</div>
46+
47+
<div id="start-with-ethereum-flow" className="flex flex-col gap-12">
48+
<StartWithEthereumFlow locale={locale} newToCryptoWallets={wallets} />
49+
</div>
50+
51+
<div className="flex w-full flex-col gap-12 rounded-2xl border border-accent-c/10 bg-gradient-to-t from-accent-c/10 from-20% to-accent-c/5 to-60% px-12 py-16 md:flex-row dark:from-accent-c/20 dark:to-accent-c/10">
52+
<div className="flex flex-1 flex-col gap-8">
53+
<h2 className="">{t("page-start-share-section-title")}</h2>
54+
<p>{t("page-start-share-section-description")}</p>
55+
<div className="flex w-full md:w-auto">
56+
<ShareModal />
57+
</div>
58+
</div>
59+
<div className="flex max-w-[450px] flex-col items-center justify-center">
60+
<Image src={ManDogeImage} alt={t("page-start-man-doge-alt")} />
61+
</div>
62+
</div>
63+
</div>
64+
</MainArticle>
3465
)
3566
}
3667

@@ -41,11 +72,13 @@ export async function generateMetadata({
4172
}) {
4273
const { locale } = await params
4374

75+
const t = await getTranslations({ locale, namespace: "page-start" })
76+
4477
return await getMetadata({
4578
locale,
4679
slug: ["start"],
47-
title: "Start with crypto",
48-
description: "Your gateway to the world of ethereum",
80+
title: t("page-start-meta-title"),
81+
description: t("page-start-meta-description"),
4982
image: "/images/heroes/developers-hub-hero.jpg",
5083
})
5184
}

src/components/StartWithEthereumFlow/ShareModal.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client"
2+
13
import { useState } from "react"
24
import { FaLink, FaXTwitter } from "react-icons/fa6"
35
import { MdCheck } from "react-icons/md"

0 commit comments

Comments
 (0)