virastack 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/nextjs/next.config.ts +1 -1
- package/templates-i18n/nextjs/next.config.ts +1 -1
- package/templates-i18n/nextjs/src/app/[locale]/[...rest]/page.tsx +5 -0
- package/templates-i18n/nextjs/src/app/[locale]/layout.tsx +8 -6
- package/templates-i18n/nextjs/src/app/layout.tsx +6 -0
- package/templates-i18n/nextjs/src/app/not-found.tsx +13 -0
- package/templates-i18n/nextjs/src/i18n/request.ts +3 -5
- package/templates-i18n/nextjs/src/proxy.ts +1 -8
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@ import type { Metadata } from "next";
|
|
|
2
2
|
import { Inter } from "next/font/google";
|
|
3
3
|
import { notFound } from "next/navigation";
|
|
4
4
|
|
|
5
|
-
import { NextIntlClientProvider } from "next-intl";
|
|
6
|
-
import {
|
|
5
|
+
import { hasLocale, NextIntlClientProvider } from "next-intl";
|
|
6
|
+
import { setRequestLocale } from "next-intl/server";
|
|
7
7
|
import { NuqsAdapter } from "nuqs/adapters/next/app";
|
|
8
8
|
|
|
9
9
|
import { defaultMetadata } from "@/config/seo.config";
|
|
@@ -24,6 +24,10 @@ const inter = Inter({
|
|
|
24
24
|
|
|
25
25
|
export const metadata: Metadata = defaultMetadata;
|
|
26
26
|
|
|
27
|
+
export function generateStaticParams() {
|
|
28
|
+
return routing.locales.map((locale) => ({ locale }));
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
export default async function RootLayout({
|
|
28
32
|
children,
|
|
29
33
|
params,
|
|
@@ -33,14 +37,12 @@ export default async function RootLayout({
|
|
|
33
37
|
}>) {
|
|
34
38
|
const { locale } = await params;
|
|
35
39
|
|
|
36
|
-
if (!routing.locales
|
|
40
|
+
if (!hasLocale(routing.locales, locale)) {
|
|
37
41
|
notFound();
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
setRequestLocale(locale);
|
|
41
45
|
|
|
42
|
-
const messages = await getMessages();
|
|
43
|
-
|
|
44
46
|
return (
|
|
45
47
|
<html
|
|
46
48
|
lang={locale}
|
|
@@ -49,7 +51,7 @@ export default async function RootLayout({
|
|
|
49
51
|
data-scroll-behavior="smooth"
|
|
50
52
|
>
|
|
51
53
|
<body className="flex min-h-full flex-col antialiased" suppressHydrationWarning>
|
|
52
|
-
<NextIntlClientProvider
|
|
54
|
+
<NextIntlClientProvider>
|
|
53
55
|
<NuqsAdapter>
|
|
54
56
|
<Providers>{children}</Providers>
|
|
55
57
|
</NuqsAdapter>
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { hasLocale } from "next-intl";
|
|
1
2
|
import { getRequestConfig } from "next-intl/server";
|
|
2
3
|
|
|
3
4
|
import { routing } from "./routing";
|
|
4
5
|
|
|
5
6
|
export default getRequestConfig(async ({ requestLocale }) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (!locale || !routing.locales.includes(locale as "en" | "tr")) {
|
|
9
|
-
locale = routing.defaultLocale;
|
|
10
|
-
}
|
|
7
|
+
const requested = await requestLocale;
|
|
8
|
+
const locale = hasLocale(routing.locales, requested) ? requested : routing.defaultLocale;
|
|
11
9
|
|
|
12
10
|
return {
|
|
13
11
|
locale,
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import type { NextRequest } from "next/server";
|
|
2
|
-
|
|
3
1
|
import createMiddleware from "next-intl/middleware";
|
|
4
2
|
|
|
5
3
|
import { routing } from "./i18n/routing";
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default async function proxy(request: NextRequest) {
|
|
10
|
-
return handleI18nRouting(request);
|
|
11
|
-
}
|
|
5
|
+
export default createMiddleware(routing);
|
|
12
6
|
|
|
13
7
|
export const config = {
|
|
14
|
-
// Match all pathnames except for api, trpc, _next, _vercel, and static files
|
|
15
8
|
matcher: "/((?!api|trpc|_next|_vercel|.*\\..*).*)",
|
|
16
9
|
};
|