-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a5936c
commit 484478d
Showing
4 changed files
with
72 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import Home from "@/features/home"; | ||
import { locales } from "@/lib/config"; | ||
import { unstable_setRequestLocale } from "next-intl/server"; | ||
import { notFound } from "next/navigation"; | ||
|
||
type Props = { | ||
params: { | ||
locale: string; | ||
}; | ||
}; | ||
|
||
export default function HomePage({ params: { locale } }: Props) { | ||
if (!locales.includes(locale as any)) notFound(); | ||
unstable_setRequestLocale(locale); | ||
|
||
export default function HomePage() { | ||
return <Home />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
import { unstable_setRequestLocale } from "next-intl/server"; | ||
import { redirect } from "@/lib/navigation"; | ||
import { notFound } from "next/navigation"; | ||
import { locales } from "@/lib/config"; | ||
|
||
type Props = { | ||
params: { | ||
locale: string; | ||
}; | ||
}; | ||
|
||
export default function RootPage({ params: { locale } }: Props) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (!locales.includes(locale as any)) notFound(); | ||
unstable_setRequestLocale(locale); | ||
|
||
export default function RootPage() { | ||
redirect("/en"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
import createMiddleware from "next-intl/middleware"; | ||
import { locales } from "./lib/config"; | ||
// import { locales } from "./lib/config"; | ||
import { NextRequest } from "next/server"; | ||
|
||
export default createMiddleware({ | ||
locales: locales, | ||
defaultLocale: "id", | ||
localePrefix: "as-needed", | ||
}); | ||
export default async function middleware(request: NextRequest) { | ||
const defaultLocale = request.headers.get("x-next-intl-locale") || "id"; | ||
|
||
const handleI18nRouting = createMiddleware({ | ||
locales: ["en", "id"], | ||
defaultLocale, | ||
localePrefix: "as-needed", | ||
alternateLinks: false, | ||
}); | ||
const response = handleI18nRouting(request); | ||
|
||
response.headers.set("x-next-intl-locale", defaultLocale); | ||
|
||
return response; | ||
} | ||
|
||
export const config = { | ||
// matcher: ["/", "/(id)/:path*"], | ||
matcher: ["/((?!api|_next|_vercel|.*\\..*).*)"], | ||
}; |