File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 11import { BlogCard } from "@/app/[locale]/blog/BlogCard" ;
2- import { Locale } from "@/i18n/routing" ;
2+ import { Locale , LOCALES } from "@/i18n/routing" ;
33import { getPosts } from "@/lib/getBlogs" ;
44import { constructMetadata } from "@/lib/metadata" ;
55import { Metadata } from "next" ;
@@ -45,3 +45,7 @@ export default async function Page({ params }: { params: Params }) {
4545 </ div >
4646 ) ;
4747}
48+
49+ export async function generateStaticParams ( ) {
50+ return LOCALES . map ( ( locale ) => ( { locale } ) ) ;
51+ }
Original file line number Diff line number Diff line change @@ -14,8 +14,12 @@ import "@/styles/globals.css";
1414import "@/styles/loading.css" ;
1515import { Analytics } from "@vercel/analytics/react" ;
1616import { Metadata , Viewport } from "next" ;
17- import { NextIntlClientProvider } from "next-intl" ;
18- import { getMessages , getTranslations } from "next-intl/server" ;
17+ import { hasLocale , NextIntlClientProvider } from "next-intl" ;
18+ import {
19+ getMessages ,
20+ getTranslations ,
21+ setRequestLocale ,
22+ } from "next-intl/server" ;
1923import { ThemeProvider } from "next-themes" ;
2024import { notFound } from "next/navigation" ;
2125
@@ -53,10 +57,12 @@ export default async function LocaleLayout({
5357 const { locale } = await params ;
5458
5559 // Ensure that the incoming `locale` is valid
56- if ( ! routing . locales . includes ( locale as any ) ) {
60+ if ( ! hasLocale ( routing . locales , locale ) ) {
5761 notFound ( ) ;
5862 }
5963
64+ setRequestLocale ( locale ) ;
65+
6066 // Providing all messages to the client
6167 // side is the easiest way to get started
6268 const messages = await getMessages ( ) ;
You can’t perform that action at this time.
0 commit comments