Skip to content

Commit 4fefd4b

Browse files
committed
new strategy to build static pages
1 parent 5c532a7 commit 4fefd4b

File tree

11 files changed

+38
-61
lines changed

11 files changed

+38
-61
lines changed

app/[locale]/10years/page.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
} from "./_components/utils"
4141
import TenYearJsonLD from "./page-jsonld"
4242

43-
import { routing } from "@/i18n/routing"
4443
import {
4544
getHolderEvents,
4645
getTransferEvents,
@@ -411,12 +410,6 @@ const Page = async ({ params }: { params: PageParams }) => {
411410
)
412411
}
413412

414-
export async function generateStaticParams() {
415-
return routing.locales.map((locale) => ({
416-
locale,
417-
}))
418-
}
419-
420413
export async function generateMetadata({
421414
params,
422415
}: {

app/[locale]/[...slug]/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { getLayoutFromSlug } from "@/lib/utils/layout"
1717
import { checkPathValidity, getPostSlugs } from "@/lib/utils/md"
1818
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
1919

20-
import { LOCALES_CODES } from "@/lib/constants"
20+
import { STATIC_LOCALES } from "@/lib/constants"
2121

2222
import SlugJsonLD from "./page-jsonld"
2323

@@ -32,8 +32,8 @@ export default async function Page({ params }: { params: SlugPageParams }) {
3232
const { locale, slug: slugArray } = params
3333

3434
// Check if this specific path is in our valid paths
35-
const validPaths = (await generateStaticParams()) as SlugPageParams[]
36-
const isValidPath = checkPathValidity(validPaths, params)
35+
const slugs = await getPostSlugs("/")
36+
const isValidPath = checkPathValidity(slugs, "/" + slugArray.join("/"))
3737

3838
if (!isValidPath) notFound()
3939

@@ -107,7 +107,7 @@ export async function generateStaticParams() {
107107
try {
108108
const slugs = await getPostSlugs("/")
109109

110-
return LOCALES_CODES.flatMap((locale) =>
110+
return STATIC_LOCALES.flatMap((locale) =>
111111
slugs.map((slug) => ({
112112
slug: slug.split("/").slice(1),
113113
locale,

app/[locale]/get-eth/page.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
4949

5050
import GetEthPageJsonLD from "./page-jsonld"
5151

52-
import { routing } from "@/i18n/routing"
5352
import uniswap from "@/public/images/dapps/uni.png"
5453
import dapps from "@/public/images/doge-computer.png"
5554
import bancor from "@/public/images/exchanges/bancor.png"
@@ -426,10 +425,6 @@ export default async function Page({ params }: { params: PageParams }) {
426425
)
427426
}
428427

429-
export async function generateStaticParams() {
430-
return routing.locales.map((locale) => ({ locale }))
431-
}
432-
433428
export async function generateMetadata({
434429
params,
435430
}: {

app/[locale]/layer-2/networks/_components/networks.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use client"
22

3+
import { Suspense } from "react"
4+
35
import CalloutSSR from "@/components/CalloutSSR"
46
import { ContentHero, ContentHeroProps } from "@/components/Hero"
57
import Layer2NetworksTable from "@/components/Layer2NetworksTable"
@@ -29,11 +31,13 @@ const Layer2Networks = ({ layer2Data, locale, mainnetData }) => {
2931
<MainArticle className="relative flex flex-col">
3032
<ContentHero {...heroProps} />
3133

32-
<Layer2NetworksTable
33-
layer2Data={layer2Data}
34-
locale={locale}
35-
mainnetData={mainnetData}
36-
/>
34+
<Suspense fallback={null}>
35+
<Layer2NetworksTable
36+
layer2Data={layer2Data}
37+
locale={locale}
38+
mainnetData={mainnetData}
39+
/>
40+
</Suspense>
3741

3842
<div id="more-advanced-cta" className="w-full px-8 py-9">
3943
<div className="flex flex-col gap-8 bg-main-gradient px-12 py-14">

app/[locale]/layer-2/page.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { BASE_TIME_UNIT } from "@/lib/constants"
2222
import Layer2Page from "./_components/layer-2"
2323
import Layer2PageJsonLD from "./page-jsonld"
2424

25-
import { routing } from "@/i18n/routing"
2625
import { fetchGrowThePie } from "@/lib/api/fetchGrowThePie"
2726
import { fetchL2beat } from "@/lib/api/fetchL2beat"
2827

@@ -89,12 +88,6 @@ const Page = async ({ params }: { params: PageParams }) => {
8988
)
9089
}
9190

92-
export async function generateStaticParams() {
93-
return routing.locales.map((locale) => ({
94-
locale,
95-
}))
96-
}
97-
9891
export async function generateMetadata({
9992
params,
10093
}: {

app/[locale]/layout.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Matomo from "@/components/Matomo"
1111
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
1212
import { getLocaleTimestamp } from "@/lib/utils/time"
1313

14+
import { STATIC_LOCALES } from "@/lib/constants"
15+
1416
import Providers from "./providers"
1517

1618
import "@/styles/global.css"
@@ -32,6 +34,12 @@ const ibmPlexMono = IBM_Plex_Mono({
3234
variable: "--font-mono",
3335
})
3436

37+
export async function generateStaticParams() {
38+
return STATIC_LOCALES.map((locale) => ({
39+
locale,
40+
}))
41+
}
42+
3543
export default async function LocaleLayout({
3644
children,
3745
params: { locale },

app/[locale]/page.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ import AppsHighlight from "./apps/_components/AppsHighlight"
8686
import IndexPageJsonLD from "./page-jsonld"
8787
import { getActivity, getUpcomingEvents } from "./utils"
8888

89-
import { routing } from "@/i18n/routing"
9089
import { fetchCommunityEvents } from "@/lib/api/calendarEvents"
9190
import { fetchApps } from "@/lib/api/fetchApps"
9291
import { fetchBeaconchainEpoch } from "@/lib/api/fetchBeaconchainEpoch"
@@ -1002,12 +1001,6 @@ const Page = async ({ params }: { params: PageParams }) => {
10021001
)
10031002
}
10041003

1005-
export async function generateStaticParams() {
1006-
return routing.locales.map((locale) => ({
1007-
locale,
1008-
}))
1009-
}
1010-
10111004
export async function generateMetadata({
10121005
params,
10131006
}: {

app/[locale]/wallets/find-wallet/page.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import {
2323

2424
import FindWalletPageJsonLD from "./page-jsonld"
2525

26-
import { routing } from "@/i18n/routing"
27-
2826
const Page = async ({ params }: { params: PageParams }) => {
2927
const { locale } = params
3028
const t = await getTranslations({
@@ -84,12 +82,6 @@ const Page = async ({ params }: { params: PageParams }) => {
8482
)
8583
}
8684

87-
export async function generateStaticParams() {
88-
return routing.locales.map((locale) => ({
89-
locale,
90-
}))
91-
}
92-
9385
export async function generateMetadata({
9486
params,
9587
}: {

app/[locale]/wallets/page.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComponentPropsWithRef } from "react"
1+
import { ComponentPropsWithRef, Suspense } from "react"
22
import { pick } from "lodash"
33
import {
44
getMessages,
@@ -305,14 +305,16 @@ const Page = async ({ params }: { params: PageParams }) => {
305305

306306
{locale === "en" ? (
307307
<div className="my-20 w-full px-0 py-4">
308-
<Simulator data={walletOnboardingSimData}>
309-
<p className="mb-2 text-lg italic leading-base text-body-medium md:text-xl lg:text-2xl">
310-
Interactive tutorial
311-
</p>
312-
<h2 className="m-0 text-3xl font-bold leading-[115%] lg:text-5xl">
313-
How to use a wallet
314-
</h2>
315-
</Simulator>
308+
<Suspense fallback={null}>
309+
<Simulator data={walletOnboardingSimData}>
310+
<p className="mb-2 text-lg italic leading-base text-body-medium md:text-xl lg:text-2xl">
311+
Interactive tutorial
312+
</p>
313+
<h2 className="m-0 text-3xl font-bold leading-[115%] lg:text-5xl">
314+
How to use a wallet
315+
</h2>
316+
</Simulator>
317+
</Suspense>
316318
</div>
317319
) : (
318320
<div className="my-12 mt-4 w-full border-t bg-gradient-main px-0 py-16 lg:mt-8">

src/lib/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const BUILD_LOCALES = process.env.NEXT_PUBLIC_BUILD_LOCALES
2323
export const LOCALES_CODES = BUILD_LOCALES
2424
? BUILD_LOCALES.split(",")
2525
: i18nConfig.map(({ code }) => code)
26+
export const STATIC_LOCALES = process.env.NEXT_PUBLIC_STATIC_LOCALES
27+
? process.env.NEXT_PUBLIC_STATIC_LOCALES.split(",")
28+
: []
2629

2730
// Site urls
2831
export const SITE_URL =

0 commit comments

Comments
 (0)