From 99ead50d1c27324275c7967be62564e7b3f3ec12 Mon Sep 17 00:00:00 2001
From: hamster1963 <1410514192@qq.com>
Date: Mon, 30 Sep 2024 23:01:07 +0800
Subject: [PATCH 1/3] perf: force-static
---
app/[locale]/layout.tsx | 6 ++++--
next.config.mjs | 13 ++++++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx
index 9bfb02c..6b89ea5 100644
--- a/app/[locale]/layout.tsx
+++ b/app/[locale]/layout.tsx
@@ -35,6 +35,8 @@ export const viewport: Viewport = {
userScalable: false,
};
+export const dynamic = "force-static";
+
export default function LocaleLayout({
children,
params: { locale },
@@ -45,9 +47,9 @@ export default function LocaleLayout({
const messages = useMessages();
return (
-
+ {/*
-
+ */}
Date: Mon, 30 Sep 2024 23:30:34 +0800
Subject: [PATCH 2/3] perf: static rendering
---
app/[locale]/(main)/page.tsx | 8 +++++++-
app/[locale]/layout.tsx | 13 ++++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/app/[locale]/(main)/page.tsx b/app/[locale]/(main)/page.tsx
index 1f4cdb6..4de86cc 100644
--- a/app/[locale]/(main)/page.tsx
+++ b/app/[locale]/(main)/page.tsx
@@ -1,7 +1,13 @@
+import { unstable_setRequestLocale } from "next-intl/server";
import ServerList from "../../../components/ServerList";
import ServerOverview from "../../../components/ServerOverview";
-export default function Home() {
+export default function Home({
+ params: { locale },
+}: {
+ params: { locale: string };
+}) {
+ unstable_setRequestLocale(locale);
return (
diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx
index 6b89ea5..f53c433 100644
--- a/app/[locale]/layout.tsx
+++ b/app/[locale]/layout.tsx
@@ -11,6 +11,8 @@ import { Inter as FontSans } from "next/font/google";
import { ThemeProvider } from "next-themes";
import { Viewport } from "next";
import { cn } from "@/lib/utils";
+import { locales } from "@/i18n-metadata";
+import { unstable_setRequestLocale } from "next-intl/server";
const fontSans = FontSans({
subsets: ["latin"],
@@ -35,7 +37,10 @@ export const viewport: Viewport = {
userScalable: false,
};
-export const dynamic = "force-static";
+// export const dynamic = "force-static";
+export async function generateStaticParams() {
+ return locales.map((locale) => ({ locale }));
+}
export default function LocaleLayout({
children,
@@ -44,12 +49,14 @@ export default function LocaleLayout({
children: React.ReactNode;
params: { locale: string };
}) {
+ unstable_setRequestLocale(locale);
+
const messages = useMessages();
return (
- {/*
+
- */}
+
Date: Mon, 30 Sep 2024 23:37:52 +0800
Subject: [PATCH 3/3] perf: set force-static
---
app/[locale]/layout.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx
index f53c433..2410b08 100644
--- a/app/[locale]/layout.tsx
+++ b/app/[locale]/layout.tsx
@@ -37,7 +37,8 @@ export const viewport: Viewport = {
userScalable: false,
};
-// export const dynamic = "force-static";
+export const dynamic = "force-static";
+
export async function generateStaticParams() {
return locales.map((locale) => ({ locale }));
}