Skip to content

Commit cea7f8b

Browse files
committed
pass locale to hero component
1 parent e810336 commit cea7f8b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

app/[locale]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
447447
</Link>
448448
</p>
449449
</BannerNotification>
450-
<HomeHero heroImg={Hero} className="w-full" />
450+
<HomeHero heroImg={Hero} className="w-full" locale={locale} />
451451
<div className="w-full space-y-32 px-4 md:mx-6 lg:space-y-48">
452452
<div className="my-20 grid w-full grid-cols-2 gap-x-4 gap-y-8 md:grid-cols-4 md:gap-x-10">
453453
{subHeroCTAs.map(

src/components/Hero/HomeHero/index.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
import type { ClassNameProp, CommonHeroProps } from "@/lib/types"
1+
import { getTranslations } from "next-intl/server"
2+
3+
import type { ClassNameProp, CommonHeroProps, Lang } from "@/lib/types"
24

35
import LanguageMorpher from "@/components/Homepage/LanguageMorpher"
46
import { Image } from "@/components/Image"
57

6-
import useTranslation from "@/hooks/useTranslation"
7-
8-
export type HomeHeroProps = Pick<CommonHeroProps, "heroImg"> & ClassNameProp
8+
export type HomeHeroProps = Pick<CommonHeroProps, "heroImg"> &
9+
ClassNameProp & {
10+
locale: Lang
11+
}
912

10-
const HomeHero = ({ heroImg, className }: HomeHeroProps) => {
11-
const { t } = useTranslation("page-index")
13+
const HomeHero = async ({ heroImg, className, locale }: HomeHeroProps) => {
14+
const t = await getTranslations({ locale, namespace: "page-index" })
1215

1316
return (
1417
<div className={className}>
1518
<div className="h-[240px] md:h-[380px] lg:h-[480px]">
1619
<Image
1720
src={heroImg}
18-
alt={t("page-index:page-index-hero-image-alt")}
21+
alt={t("page-index-hero-image-alt")}
1922
// TODO: adjust value when the old theme breakpoints are removed (src/theme.ts)
2023
sizes="(max-width: 1504px) 100vw, 1504px"
2124
className="h-full w-full object-cover"
@@ -25,9 +28,9 @@ const HomeHero = ({ heroImg, className }: HomeHeroProps) => {
2528
<div className="flex flex-col items-center border-t-[3px] border-primary-low-contrast px-4 py-10 text-center">
2629
<LanguageMorpher />
2730
<div className="flex flex-col items-center gap-y-5 lg:max-w-2xl">
28-
<h1 className="font-black">{t("page-index:page-index-title")}</h1>
31+
<h1 className="font-black">{t("page-index-title")}</h1>
2932
<p className="max-w-96 text-md text-body-medium lg:text-lg">
30-
{t("page-index:page-index-description")}
33+
{t("page-index-description")}
3134
</p>
3235
</div>
3336
</div>

0 commit comments

Comments
 (0)