Skip to content

Commit ab31268

Browse files
authored
Merge pull request #15522 from ethereum/metadata
fix: home page metadata
2 parents 198a412 + 4dae8d4 commit ab31268

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

app/[locale]/page.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { dataLoader } from "@/lib/utils/data/dataLoader"
1313
import { isValidDate } from "@/lib/utils/date"
1414
import { existsNamespace } from "@/lib/utils/existsNamespace"
1515
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
16+
import { getMetadata } from "@/lib/utils/metadata"
1617
import { polishRSSList } from "@/lib/utils/rss"
1718
import { getLocaleTimestamp } from "@/lib/utils/time"
1819
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
@@ -127,13 +128,21 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
127128
)
128129
}
129130

130-
export async function generateMetadata() {
131-
const t = await getTranslations()
131+
export async function generateMetadata({
132+
params,
133+
}: {
134+
params: Promise<{ locale: string }>
135+
}) {
136+
const { locale } = await params
132137

133-
return {
134-
title: t("page-index.page-index-meta-title"),
135-
description: t("page-index.page-index-meta-description"),
136-
}
138+
const t = await getTranslations({ locale, namespace: "page-index" })
139+
140+
return await getMetadata({
141+
locale,
142+
slug: [""],
143+
title: t("page-index-meta-title"),
144+
description: t("page-index-meta-description"),
145+
})
137146
}
138147

139148
export default Page

src/lib/utils/metadata.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { getTranslations } from "next-intl/server"
33

44
import { DEFAULT_OG_IMAGE, SITE_URL } from "@/lib/constants"
55

6+
import { isLocaleValidISO639_1 } from "./translations"
67
import { getFullUrl } from "./url"
78

89
import { routing } from "@/i18n/routing"
@@ -71,10 +72,9 @@ export const getMetadata = async ({
7172
languages: {
7273
"x-default": xDefault,
7374
...Object.fromEntries(
74-
routing.locales.map((locale) => [
75-
locale,
76-
getFullUrl(locale, slugString),
77-
])
75+
routing.locales
76+
.filter(isLocaleValidISO639_1)
77+
.map((locale) => [locale, getFullUrl(locale, slugString)])
7878
),
7979
},
8080
},

0 commit comments

Comments
 (0)